class Civi

Class Civi

The "Civi" class provides a facade for accessing major subsystems, such as the service-container and settings manager. It serves as a bridge which allows procedural code to access important objects.

General principles: - Each function provides access to a major subsystem. - Each function performs a simple lookup. - Each function returns an interface. - Whenever possible, interfaces should be well-known (e.g. based on a standard or well-regarded provider).

Properties

static array $statics A central location for static variable storage.

Methods

cache(string $name = 'default')

Retrieve a named cache instance.

static ContainerInterface
container()

Get the service container.

static EventDispatcherInterface
dispatcher()

Get the event dispatcher.

static LockManager
lockManager()

No description

static LoggerInterface
log()

No description

static Paths
paths()

Obtain the core file/path mapper.

static mixed
service(string $id)

Fetch a service from the container.

static 
reset()

Reset all ephemeral system state, e.g. statics, singletons, containers.

resources()

No description

static SettingsBag
contactSettings(NULL|int $contactID = NULL, NULL|int $domainID = NULL)

Obtain the contact's personal settings.

static SettingsBag
settings(int|null $domainID = NULL)

Obtain the domain settings.

Details

at line 48
static CRM_Utils_Cache_Interface cache(string $name = 'default')

Retrieve a named cache instance.

Parameters

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. 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 Value

CRM_Utils_Cache_Interface NOTE: Beginning in CiviCRM v5.4, the cache instance complies with PSR-16 (\Psr\SimpleCache\CacheInterface).

at line 57
static ContainerInterface container()

Get the service container.

Return Value

ContainerInterface

at line 66
static EventDispatcherInterface dispatcher()

Get the event dispatcher.

Return Value

EventDispatcherInterface

at line 73
static LockManager lockManager()

Return Value

LockManager

at line 80
static LoggerInterface log()

Return Value

LoggerInterface

at line 89
static Paths paths()

Obtain the core file/path mapper.

Return Value

Paths

at line 100
static mixed service(string $id)

Fetch a service from the container.

Parameters

string $id The service ID.

Return Value

mixed

at line 108
static reset()

Reset all ephemeral system state, e.g. statics, singletons, containers.

at line 116
static CRM_Core_Resources resources()

Return Value

CRM_Core_Resources

at line 132
static SettingsBag contactSettings(NULL|int $contactID = NULL, NULL|int $domainID = NULL)

Obtain the contact's personal settings.

Parameters

NULL|int $contactID For the default/active user's contact, leave $domainID as NULL.
NULL|int $domainID For the default domain, leave $domainID as NULL.

Return Value

SettingsBag

Exceptions

CRM_Core_Exception If there is no contact, then there's no SettingsBag, and we'll throw an exception.

at line 143
static SettingsBag settings(int|null $domainID = NULL)

Obtain the domain settings.

Parameters

int|null $domainID For the default domain, leave $domainID as NULL.

Return Value

SettingsBag