public static \Joomla\CMS\Cache\CacheController
getInstance
(mixed $type = 'output', mixed $options = array())
/**
* Returns a reference to a cache adapter object, always creating it
*
* @param string $type The cache object type to instantiate; default is output.
* @param array $options Array of options
*
* @return CacheController
*
* @since 1.7.0
* @throws \RuntimeException
* @deprecated 5.0 Use the cache controller factory instead
*/
public static function getInstance($type = 'output', $options = array())
{
@trigger_error(sprintf('%s() is deprecated. The cache controller should be fetched from the factory.', __METHOD__), E_USER_DEPRECATED);
try {
return Factory::getContainer()->get(CacheControllerFactoryInterface::class)->createCacheController($type, $options);
} catch (\RuntimeException $e) {
$type = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $type));
$class = 'JCacheController' . ucfirst($type);
if (!class_exists($class)) {
// Search for the class file in the Cache include paths.
$path = Path::find(self::addIncludePath(), strtolower($type) . '.php');
if ($path !== false) {
\JLoader::register($class, $path);
}
// The class should now be loaded
if (!class_exists($class)) {
throw new \RuntimeException('Unable to load Cache Controller: ' . $type, 500);
}
// Only trigger a deprecation notice if the file and class are found
@trigger_error('Support for including cache controllers using path lookup is deprecated and will be removed in 5.0.' . ' Use a custom cache controller factory instead.', E_USER_DEPRECATED);
}
return new $class($options);
}
}