Esempio n. 1
0
 public static function init($registryPath = '')
 {
     $sysRegistryFile = $registryPath . 'system_registry.php';
     if (file_exists($sysRegistryFile)) {
         static::$_registry = (require_once $sysRegistryFile);
     }
 }
 public static function get($name, $useAlias = true)
 {
     if ($useAlias && isset(static::$_aliasMap[$name])) {
         $name = static::$_aliasMap[$name];
     }
     if (empty(static::$_config[$name])) {
         throw new MissingDatasourceConfigException(['name' => $name]);
     }
     if (empty(static::$_registry)) {
         static::$_registry = new NoSqlConnectionRegistry();
     }
     if (isset(static::$_registry->{$name})) {
         return static::$_registry->{$name};
     }
     return static::$_registry->load($name, static::$_config[$name]);
 }
Esempio n. 3
0
 /**
  * Finds and builds the instance of the required engine class.
  *
  * @param string $name Name of the config array that needs an engine instance built
  * @return void
  * @throws \InvalidArgumentException When a cache engine cannot be created.
  */
 protected static function _buildEngine($name)
 {
     if (empty(static::$_registry)) {
         static::$_registry = new CacheRegistry();
     }
     if (empty(static::$_config[$name]['className'])) {
         throw new InvalidArgumentException(sprintf('The "%s" cache configuration does not exist.', $name));
     }
     $config = static::$_config[$name];
     static::$_registry->load($name, $config);
     if (!empty($config['groups'])) {
         foreach ($config['groups'] as $group) {
             static::$_groups[$group][] = $name;
             static::$_groups[$group] = array_unique(static::$_groups[$group]);
             sort(static::$_groups[$group]);
         }
     }
 }
Esempio n. 4
0
 /**
  * Returns the Cache Registry instance used for creating and using cache adapters.
  * Also allows for injecting of a new registry instance.
  *
  * @param \Cake\Core\ObjectRegistry $registry Injectable registry object.
  * @return \Cake\Core\ObjectRegistry
  */
 public static function registry(ObjectRegistry $registry = null)
 {
     if ($registry) {
         static::$_registry = $registry;
     }
     if (empty(static::$_registry)) {
         static::$_registry = new CacheRegistry();
     }
     return static::$_registry;
 }
Esempio n. 5
0
 /**
  * Reset all the connected loggers.  This is useful to do when changing the logging
  * configuration or during testing when you want to reset the internal state of the
  * Log class.
  *
  * Resets the configured logging adapters, as well as any custom logging levels.
  * This will also clear the configuration data.
  *
  * @return void
  */
 public static function reset()
 {
     static::$_registry = null;
     static::$_config = [];
     static::$_dirtyConfig = true;
 }
Esempio n. 6
0
 /**
  * Get registry of all contracts.
  *
  * @return  \ArrayObject
  */
 public static function getRegistry()
 {
     if (null === static::$_registry) {
         static::$_registry = new \ArrayObject();
     }
     return static::$_registry;
 }
 /**
  * Reset registry
  */
 public static function reset()
 {
     static::$_registry = [];
 }