Blame view
sources/lib/private/appframework/utility/simplecontainer.php
1.02 KB
|
31b7f2792
|
1 2 3 |
<?php namespace OC\AppFramework\Utility; |
|
31b7f2792
|
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
/**
* Class SimpleContainer
*
* SimpleContainer is a simple implementation of IContainer on basis of \Pimple
*/
class SimpleContainer extends \Pimple implements \OCP\IContainer {
/**
* @param string $name name of the service to query for
* @return object registered service for the given $name
*/
public function query($name) {
return $this->offsetGet($name);
}
function registerParameter($name, $value)
{
$this[$name] = $value;
}
/**
* The given closure is call the first time the given service is queried.
* The closure has to return the instance for the given service.
* Created instance will be cached in case $shared is true.
*
* @param string $name name of the service to register another backend for
|
|
6d9380f96
|
30 |
* @param \Closure $closure the closure to be called on service creation |
|
31b7f2792
|
31 32 33 34 35 36 37 38 39 40 |
*/
function registerService($name, \Closure $closure, $shared = true)
{
if ($shared) {
$this[$name] = \Pimple::share($closure);
} else {
$this[$name] = $closure;
}
}
}
|