本文整理汇总了PHP中Cake\Cache\Cache::configured方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::configured方法的具体用法?PHP Cache::configured怎么用?PHP Cache::configured使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Cache\Cache
的用法示例。
在下文中一共展示了Cache::configured方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listPrefixes
/**
* Show a list of all defined cache prefixes.
*
* @return void
*/
public function listPrefixes()
{
$prefixes = Cache::configured();
foreach ($prefixes as $prefix) {
$this->out($prefix);
}
}
示例2: __construct
/**
* TinyAuthorize::__construct()
*
* @param \Cake\Controller\ComponentRegistry $registry
* @param array $config
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(ComponentRegistry $registry, array $config = [])
{
$config += (array) Configure::read('TinyAuth');
$config += $this->_defaultConfig;
if (!$config['prefixes'] && !empty($config['authorizeByPrefix'])) {
throw new Exception('Invalid TinyAuthorization setup for `authorizeByPrefix`. Please declare `prefixes`.');
}
parent::__construct($registry, $config);
if (!in_array($config['cache'], Cache::configured())) {
throw new Exception(sprintf('Invalid TinyAuthorization cache `%s`', $config['cache']));
}
}
示例3: initialize
/**
* Initialize - install cache spies.
*
* @return void
*/
public function initialize()
{
foreach (Cache::configured() as $name) {
$config = Cache::config($name);
if ($config['className'] instanceof DebugEngine) {
$instance = $config['className'];
} else {
Cache::drop($name);
$instance = new DebugEngine($config);
Cache::config($name, $instance);
}
$this->_instances[$name] = $instance;
}
}
示例4: _prepareConfig
/**
* @param array $config
* @throws \Cake\Core\Exception\Exception
* @return array
*/
protected function _prepareConfig(array $config)
{
$config += $this->_defaultConfig();
if (!$config['prefixes'] && !empty($config['authorizeByPrefix'])) {
throw new Exception('Invalid TinyAuthorization setup for `authorizeByPrefix`. Please declare `prefixes`.');
}
if (!in_array($config['cache'], Cache::configured())) {
throw new Exception(sprintf('Invalid TinyAuth cache `%s`', $config['cache']));
}
if ($config['autoClearCache'] === null) {
$config['autoClearCache'] = Configure::read('debug');
}
return $config;
}
示例5: testConfigured
/**
* test that configured returns an array of the currently configured cache
* config
*
* @return void
*/
public function testConfigured()
{
Cache::drop('default');
$result = Cache::configured();
$this->assertContains('_cake_core_', $result);
$this->assertNotContains('default', $result, 'Unconnected engines should not display.');
}
示例6: cache
/**
* Get/Set caching.
*
* @param null|bool|string $cache Cache config name to use, If true is passed, 'cake_pdf' will be used.
* @throws \Cake\Core\Exception\Exception
* @return mixed
*/
public function cache($cache = null)
{
if ($cache === null) {
return $this->_cache;
}
if ($cache === false) {
$this->_cache = false;
return $this;
}
if ($cache === true) {
$cache = 'cake_pdf';
}
if (!in_array($cache, Cache::configured())) {
throw new Exception(sprintf('CakePdf cache is not configured: %s', $cache));
}
$this->_cache = $cache;
return $this;
}
示例7: function
use Cake\Datasource\ConnectionManager;
$findRoot = function ($root) {
do {
$lastRoot = $root;
$root = dirname($root);
if (is_dir($root . '/vendor/cakephp/cakephp')) {
return $root;
}
} while ($root !== $lastRoot);
throw new Exception('Cannot find the root of the application, unable to run tests');
};
$root = $findRoot(__FILE__);
unset($findRoot);
chdir($root);
require_once 'vendor/cakephp/cakephp/src/basics.php';
require_once 'vendor/autoload.php';
define('ROOT', $root . DS . 'tests' . DS . 'test_app' . DS);
define('APP', ROOT . 'TestApp' . DS);
define('TMP', sys_get_temp_dir() . DS);
Configure::write('debug', true);
Configure::write('App', ['namespace' => 'TestApp', 'paths' => ['plugins' => [ROOT . 'Plugin' . DS]]]);
if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite:///:memory:');
}
ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
// Wipe out any accumulated caches before running tests.
foreach (\Cake\Cache\Cache::configured() as $key) {
\Cake\Cache\Cache::clear(false, $key);
echo "Cleared cache: {$key}\n";
}
echo PHP_EOL;