コード例 #1
0
ファイル: CacheShell.php プロジェクト: nrother/cakephp
 /**
  * Show a list of all defined cache prefixes.
  *
  * @return void
  */
 public function listPrefixes()
 {
     $prefixes = Cache::configured();
     foreach ($prefixes as $prefix) {
         $this->out($prefix);
     }
 }
コード例 #2
0
 /**
  * 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
0
ファイル: CachePanel.php プロジェクト: JesseDarellMoore/CS499
 /**
  * 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
0
 /**
  * @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
0
ファイル: CacheTest.php プロジェクト: maitrepylos/nazeweb
 /**
  * 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
0
ファイル: CakePdf.php プロジェクト: Iteracode/CakePdf
 /**
  * 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
0
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;