X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi.php;h=12b2119b45bc846ca7472b3ac6a518c5140532fb;hb=ecaa82003d46edf98d72a9cf3ed4e471d21e6ab2;hp=8acfdba76862963e124de00335dd48a67e58806c;hpb=0287d2706caeb5b779f8378f6490670c6ee88bd2;p=civicrm-core.git diff --git a/Civi.php b/Civi.php index 8acfdba768..12b2119b45 100644 --- a/Civi.php +++ b/Civi.php @@ -18,7 +18,7 @@ class Civi { /** * A central location for static variable storage. - * + * @var array * @code * `Civi::$statics[__CLASS__]['foo'] = 'bar'; * @endcode @@ -32,6 +32,15 @@ class Civi { * 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. + * Ex: 'short' or 'default' is useful for high-speed, short-lived cache data. + * This is appropriate if you believe that latency (millisecond-level + * read time) is the main factor. For example: caching data from + * a couple SQL queries. + * Ex: 'long' can be useful for longer-lived cache data. It's appropriate if + * you believe that longevity (e.g. surviving for several hours or a day) + * is more important than millisecond-level access time. For example: + * caching the result of a simple metadata-query. + * * @return CRM_Utils_Cache_Interface * NOTE: Beginning in CiviCRM v5.4, the cache instance complies with * PSR-16 (\Psr\SimpleCache\CacheInterface). @@ -108,6 +117,22 @@ class Civi { return CRM_Core_Resources::singleton(); } + /** + * Obtain the contact's personal settings. + * + * @param NULL|int $contactID + * For the default/active user's contact, leave $domainID as NULL. + * @param NULL|int $domainID + * For the default domain, leave $domainID as NULL. + * @return \Civi\Core\SettingsBag + * @throws CRM_Core_Exception + * If there is no contact, then there's no SettingsBag, and we'll throw + * an exception. + */ + public static function contactSettings($contactID = NULL, $domainID = NULL) { + return \Civi\Core\Container::getBootService('settings_manager')->getBagByContact($domainID, $contactID); + } + /** * Obtain the domain settings. *