Commit 711aa5d7 authored by totten's avatar totten

\Civi - Add facade accessing system services

parent ba3ce4fb
<?php
/**
* 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).
*/
class Civi {
/**
* A central location for static variable storage.
*
* @code
* `Civi::$statics[__CLASS__]['foo'] = 'bar';
* @endcode
*/
public static $statics = array();
/**
* Get the service container.
*
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
public static function container() {
return Civi\Core\Container::singleton();
}
/**
* Fetch a service from the container.
*
* @param string $id
* The service ID.
* @return mixed
*/
public static function service($id) {
return \Civi\Core\Container::singleton()->get($id);
}
/**
* Reset all ephemeral system state, e.g. statics,
* singletons, containers.
*/
public static function reset() {
Civi\Core\Container::singleton(TRUE);
self::$statics = array();
}
}
......@@ -2,6 +2,7 @@
"autoload": {
"psr-0": {
"PHPUnit_": ["packages/"],
"Civi": "",
"Civi\\": [".", "tests/phpunit/"]
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment