public function testDataReferenceInEvents() { $this->object->on('beforeServiceLoaded', function (BeforeServiceLoadedEvent $event) { $data = $event->getDefinition()->getData(); $data['testTwo'] = "test"; $event->getDefinition()->setData($data); }); $self = $this; $this->object->on('afterServiceLoaded', function (AfterServiceLoadedEvent $event) use($self) { $data = $event->getDefinition()->getData(); $self->assertTrue(isset($data['testTwo'])); }); $this->object->set('service.with.data', "da service", false, array('testOne' => true)); $this->object->get('service.with.data'); }
public function render($pageName, Container $services, Context $context, array $config, array $params = array()) { $template = $this->calculateTemplate($pageName, $context, $config); $pagesPath = $this->path->calculate(array($config['directories']['pages'])); $path = str_replace($pagesPath, '', $template); return $services->get($this->twig)->render($path, $params); }
public function testSharedSetAndGetDefinition() { $this->assertFalse($this->object->has('test')); $def = ClassDefinition::factory('stdClass'); $this->object->set('test', $def->setShared(true)); $this->assertTrue($this->object->has('test')); $inst = $this->object->get('test'); $this->assertInstanceOf('\\stdClass', $inst); $this->assertTrue($inst === $this->object->get('test')); }
/** * * @param \Fwk\Di\Container $container * * @return \Symfony\Component\Console\Application */ protected function getConsoleApplication(Container $container) { return $container->get($this->consoleService); }
/** * Return the value of the referenced Definition * * @param Container $container The Di Container * @param null|string $name Name of the current definition (if any) * * @return mixed */ public function invoke(Container $container, $name = null) { try { $return = $container->get($this->name); } catch (DefinitionNotFoundException $exp) { throw new InvalidReferenceException($this->name, $name, $exp); } return $return; }
/** * * @param string $name * * @return DataSource */ public function factory($name) { return $this->services->get('cms.ds.' . $name); }