public static $statics = array();
/**
- * EXPERIMENTAL. Retrieve a named cache instance.
- *
- * This interface is flagged as experimental due to political
- * ambiguity in PHP community -- PHP-FIG has an open but
- * somewhat controversial draft standard for caching. Based on
- * the current draft, it's expected that this function could
- * simultaneously support both CRM_Utils_Cache_Interface and
- * PSR-6, but that depends on whether PSR-6 changes any more.
+ * Retrieve a named cache instance.
*
* @param string $name
* The name of the cache. The 'default' cache is biased toward
* high-performance caches (eg memcache/redis/apc) when
* available and falls back to single-request (static) caching.
* @return CRM_Utils_Cache_Interface
+ * NOTE: Beginning in CiviCRM v5.4, the cache instance complies with
+ * PSR-16 (\Psr\SimpleCache\CacheInterface).
*/
public static function cache($name = 'default') {
return \Civi\Core\Container::singleton()->get('cache.' . $name);
return Civi\Core\Container::singleton();
}
+ /**
+ * Get the event dispatcher.
+ *
+ * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface
+ */
+ public static function dispatcher() {
+ return Civi\Core\Container::singleton()->get('dispatcher');
+ }
+
+ /**
+ * @return \Civi\Core\Lock\LockManager
+ */
+ public static function lockManager() {
+ return \Civi\Core\Container::getBootService('lockManager');
+ }
+
/**
* @return \Psr\Log\LoggerInterface
*/
* @return \Civi\Core\Paths
*/
public static function paths() {
- // Paths must be available before container can boot.
- if (!isset(Civi::$statics[__CLASS__]['paths'])) {
- Civi::$statics[__CLASS__]['paths'] = new \Civi\Core\Paths();
- }
- return Civi::$statics[__CLASS__]['paths'];
+ return \Civi\Core\Container::getBootService('paths');
}
/**
* singletons, containers.
*/
public static function reset() {
- Civi\Core\Container::singleton(TRUE);
self::$statics = array();
+ Civi\Core\Container::singleton();
}
/**
* @return \Civi\Core\SettingsBag
*/
public static function settings($domainID = NULL) {
- return Civi\Core\Container::singleton()->get('settings_manager')->getBagByDomain($domainID);
+ return \Civi\Core\Container::getBootService('settings_manager')->getBagByDomain($domainID);
}
}