Exemplo n.º 1
0
 public function testListeners()
 {
     $container = new \Fwk\Di\Container();
     $this->object->execute(__DIR__ . '/../test-di.xml', $container);
     $self = $this;
     $container->on('afterServiceLoaded', function (AfterServiceLoadedEvent $event) use($self) {
         $data = $event->getDefinition()->getData();
         $self->assertTrue(isset($data['listener-override']));
         $self->assertTrue(isset($data['service-listener']));
     });
     $container->get('arrayDef');
 }
Exemplo n.º 2
0
 public function loadServices(Container $container)
 {
     $xml = array();
     $map = $this->xmlServicesMapFactory();
     foreach ($this->sources as $source) {
         $parse = $map->execute($this->getSourceXml($source));
         $res = isset($parse['services']) ? $parse['services'] : array();
         $xml[dirname($this->getSourceXml($source)->getRealPath())] = $res;
     }
     foreach ($xml as $baseDir => $data) {
         $this->set('baseDir', $baseDir);
         foreach ($data as $xmlFile => $infos) {
             $xmlMapClass = !empty($infos['xmlMap']) ? $this->propertizeString($infos['xmlMap']) : null;
             if (null !== $xmlMapClass) {
                 $def = new ClassDefinition($xmlMapClass);
                 $mapObj = $def->invoke($container);
             } else {
                 $mapObj = null;
             }
             $builder = new ContainerBuilder($mapObj);
             $builder->execute($this->propertizeString($xmlFile), $container);
         }
         $this->set('baseDir', null);
     }
 }
Exemplo n.º 3
0
 public function initServices(Container $container)
 {
     $cfg = $this->getSiteConfig();
     if (!isset($cfg['services']) || !is_array($cfg['services'])) {
         return;
     }
     $builder = new ContainerBuilder();
     $utils = new Utils\PathUtils(dirname($this->configFile));
     foreach ($cfg['services'] as $servicesXml) {
         $builder->execute($utils->calculate(array($servicesXml)), $container);
     }
 }