X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi.php;h=ae5dc6f4b1dda2f1a883542edbb0ec98c17b14dc;hb=49471b7478b55bc3868f791830c1a86b68da5fdf;hp=0d899a65f4e7594efc7a23432c8b8332594627a3;hpb=711aa5d7445d830543249aae16f338d7f4004a94;p=civicrm-core.git diff --git a/Civi.php b/Civi.php index 0d899a65f4..ae5dc6f4b1 100644 --- a/Civi.php +++ b/Civi.php @@ -25,6 +25,26 @@ class Civi { */ 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. + * + * @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 + */ + public static function cache($name = 'default') { + return \Civi\Core\Container::singleton()->get('cache.' . $name); + } + /** * Get the service container. * @@ -34,6 +54,38 @@ class Civi { 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 + */ + public static function log() { + return Civi\Core\Container::singleton()->get('psr_log'); + } + + /** + * Obtain the core file/path mapper. + * + * @return \Civi\Core\Paths + */ + public static function paths() { + return \Civi\Core\Container::getBootService('paths'); + } + /** * Fetch a service from the container. * @@ -50,8 +102,26 @@ class Civi { * singletons, containers. */ public static function reset() { - Civi\Core\Container::singleton(TRUE); self::$statics = array(); + Civi\Core\Container::singleton(); + } + + /** + * @return CRM_Core_Resources + */ + public static function resources() { + return CRM_Core_Resources::singleton(); + } + + /** + * Obtain the domain settings. + * + * @param int|null $domainID + * For the default domain, leave $domainID as NULL. + * @return \Civi\Core\SettingsBag + */ + public static function settings($domainID = NULL) { + return \Civi\Core\Container::getBootService('settings_manager')->getBagByDomain($domainID); } }