本文整理匯總了PHP中JCacheStorage::addIncludePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP JCacheStorage::addIncludePath方法的具體用法?PHP JCacheStorage::addIncludePath怎麽用?PHP JCacheStorage::addIncludePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JCacheStorage
的用法示例。
在下文中一共展示了JCacheStorage::addIncludePath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCache
/**
* Get cache handler.
*
* Note this cache will ignore the cache setting in Joomla configuration.
*
* @param string $handler The cache handler name.
* @param string $storage The storage name.
*
* @return \JCache|\JCacheController|\JCacheControllerClosure
*/
public static function getCache($handler = 'closure', $storage = 'runtime')
{
static $included = false;
if (!$included) {
\JCacheStorage::addIncludePath(__DIR__);
\JCacheController::addIncludePath(__DIR__);
$included = true;
}
$handler = $handler ?: 'closure';
$cache = \JFactory::getCache('windwalker', $handler, $storage);
$cache->setCaching(true);
return $cache;
}
示例2: getInstance
/**
* Returns a cache storage handler object, only creating it
* if it doesn't already exist.
*
* @param string $handler The cache storage handler to instantiate
* @param array $options Array of handler options
*
* @return JCacheStorageHandler A JCacheStorageHandler object
*
* @since 11.1
*/
public static function getInstance($handler = null, $options = array())
{
static $now = null;
JCacheStorage::addIncludePath(JPATH_PLATFORM . '/joomla/cache/storage');
if (!isset($handler))
{
$conf = JFactory::getConfig();
$handler = $conf->get('cache_handler');
if (empty($handler))
{
return JError::raiseWarning(500, JText::_('JLIB_CACHE_ERROR_CACHE_HANDLER_NOT_SET'));
}
}
if (is_null($now))
{
$now = time();
}
$options['now'] = $now;
//We can't cache this since options may change...
$handler = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $handler));
$class = 'JCacheStorage' . ucfirst($handler);
if (!class_exists($class))
{
// Search for the class file in the JCacheStorage include paths.
jimport('joomla.filesystem.path');
if ($path = JPath::find(JCacheStorage::addIncludePath(), strtolower($handler) . '.php'))
{
include_once $path;
}
else
{
return JError::raiseWarning(500, JText::sprintf('JLIB_CACHE_ERROR_CACHE_STORAGE_LOAD', $handler));
}
}
return new $class($options);
}