public function process() { try { /** * Session specific actions */ if ($this->container->hasService('session')) { $this->container->session->handleUserActions(); } $this->container->dispatcher->dispatch(); } catch (Exception $e) { Log::fatal('Error during initialization.', 'Core', array('Exception' => get_class($e), 'message' => $e->getMessage())); die('<h1 class="error">' . $e->getMessage() . '</h1>'); } }
/** * Returns true if the given service is defined. * * @param string $id The service identifier * * @return Boolean true if the service is defined, false otherwise */ public function hasService($id) { return isset($this->definitions[$id]) || isset($this->aliases[$id]) || parent::hasService($id); }
$t->ok($sc->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); $t->ok(!$sc->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); // ->addParameters() $t->diag('->addParameters()'); $sc = new sfServiceContainer(array('foo' => 'bar')); $sc->addParameters(array('bar' => 'foo')); $t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); $sc->addParameters(array('Bar' => 'fooz')); $t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); // ->setService() ->hasService() ->getService() $t->diag('->setService() ->hasService() ->getService()'); $sc = new sfServiceContainer(); $sc->setService('foo', $obj = new stdClass()); $t->is(spl_object_hash($sc->getService('foo')), spl_object_hash($obj), '->setService() registers a service under a key name'); $sc->foo1 = $obj1 = new stdClass(); $t->ok($sc->hasService('foo'), '->hasService() returns true if the service is defined'); $t->ok(!$sc->hasService('bar'), '->hasService() returns false if the service is not defined'); // ->getServiceIds() $t->diag('->getServiceIds()'); $sc = new sfServiceContainer(); $sc->setService('foo', $obj = new stdClass()); $sc->setService('bar', $obj = new stdClass()); $t->is($sc->getServiceIds(), array('service_container', 'foo', 'bar'), '->getServiceIds() returns all defined service ids'); class ProjectServiceContainer extends sfServiceContainer { public $__bar, $__foo_bar, $__foo_baz; public function __construct() { parent::__construct(); $this->__bar = new stdClass(); $this->__foo_bar = new stdClass();
/** * Returns true if the given service is defined. * * @param string $id The service identifier * * @return Boolean true if the service is defined, false otherwise */ public function hasService($name) { return isset($this->definitions[$name]) || parent::hasService($name); }