/** * @param Event $event * @param Application $application * @return mixed */ public function boot(Event $event, Application $application) { $config = $application->getConfig(); if (isset($config->application->sharedServices) && $config->application->sharedServices) { $injector = new Injector($application->getDI()); $injector->inject($config->application->sharedServices->toArray()); } }
public function testShouldNotInjectInvalidClass() { $di = new \Phalcon\Di\FactoryDefault(); $fooClassStr = 'class Invalid { public function register(\\Phalcon\\DiInterface $di) { $o = new \\stdClass; $o->foo = "bar"; $di->set("foo", $o); } }'; eval($fooClassStr); $exception = null; try { $injector = new Injector($di); $injector->inject(['Invalid']); } catch (\Exception $e) { $exception = $e; } $this->assertInstanceOf('\\Vegas\\Di\\Injector\\Exception\\InvalidServiceException', $exception); }