コード例 #1
0
 /**
  * startup extension manager with available extensions
  */
 public function boot()
 {
     if ($this->boot === true) {
         return;
     }
     if (($pathList = $this->extensionProvider->getPathList()) !== null) {
         $this->reflectionLoader->addPathList($pathList);
     }
     foreach ($this->extensionProvider->getEnabledList() as $extension) {
         $this->registerExtension($this->context->create($extension));
     }
     $this->boot = true;
     $this->eventBus->emit(new BootEvent($this));
 }
コード例 #2
0
ファイル: Compiler.php プロジェクト: edde-framework/edde
 public function compile(IConfigNode $root)
 {
     /**
      * @var $resource IResource
      */
     foreach ($this->resourceList as $resource) {
         list($resource, $required) = $resource;
         if ($required === true && !$resource->isAvailable()) {
             throw new CompilerException(sprintf('Requested config resource [%s] is not available.', $resource->getUri()));
         }
         $this->eventBus->emit(new ConfigResourceEvent($this, $root->addNodeList($this->handle($resource), true), $resource));
     }
     $this->eventBus->emit(new CompiledEvent($this, $root));
     return $root;
 }
コード例 #3
0
ファイル: Application.php プロジェクト: edde-framework/edde
 public function run()
 {
     try {
         $this->addComponent($this->presenter);
         $this->eventBus->emit(new StartupEvent($this));
         try {
             $this->eventBus->emit(new RunEvent($this, $this->presenter));
             $this->presenter->run();
             $this->eventBus->emit(new ShutdownEvent($this));
         } catch (ContextException $e) {
             throw new ApplicationException('Cannot create presenter; bad request.', $e->getCode(), $e);
         }
     } catch (\Exception $e) {
         $this->eventBus->emit(new ExceptionEvent($this, $e));
         throw $e;
     }
 }
コード例 #4
0
ファイル: Compiler.php プロジェクト: edde-framework/edde
 public function run(IResource $resource, array $resourceList = [])
 {
     $tree = new PiccoNode();
     $root = $this->templateLoader->load($resource);
     foreach ($resourceList as $resource) {
         $tree->addNode($this->templateLoader->load($resource));
     }
     $this->eventBus->emit(new CompileEvent($this, $root, $tree));
     $this->compile($root, $tree);
     $this->eventBus->emit(new CompiledEvent($this, $root));
     return $this->node($root);
 }
コード例 #5
0
ファイル: XmlParser.php プロジェクト: edde-framework/edde
 public function read(IResource $resource, $handler)
 {
     $value = null;
     $this->eventBus = new EventBus();
     $this->eventBus->register($handler);
     foreach ($resource as $chunk) {
         foreach ($iterator = StringUtils::createIterator($chunk) as $char) {
             switch ($char) {
                 case '<':
                     if ($value !== null) {
                         $this->eventBus->emit(new TextEvent($value));
                     }
                     $this->parseTag($iterator->setContinue());
                     $value = null;
                     break;
                 default:
                     $value .= $char;
             }
         }
     }
     return $this;
 }
コード例 #6
0
 public function factory(IContext $context, IEventBus $eventBus, array $parameterList = [])
 {
     try {
         if ($this->instance !== null) {
             if ($this->isCloneable()) {
                 $eventBus->emit(new CloneEvent($this->name, $instance = clone $this->instance));
                 return $instance;
             } else {
                 if ($this->isSingleton()) {
                     $eventBus->emit(new SingletonEvent($this->name, $this->instance));
                     return $this->instance;
                 }
             }
         }
         if ($this->lock === true) {
             throw new CircularDependencyException(sprintf("Factory [%s] is locked; isn't there some circular dependency?", $this->name));
         }
         $this->lock = true;
         $eventBus->emit(new FactoryEvent($this->name, $this->instance = $this->create($dependencyList = $this->getDependencyList($context, $parameterList)), $dependencyList));
         $this->lock = false;
         return $this->instance;
     } catch (\Exception $e) {
         $eventBus->emit(new ExceptionEvent($this->name, $e));
         $this->lock = false;
         throw $e;
     }
 }
コード例 #7
0
 public function factory(IContext $context, IEventBus $eventBus, array $parameterList = [])
 {
     $eventBus->emit(new SingletonEvent($this->name, $this->instance));
     return $this->instance;
 }
コード例 #8
0
 public function onInstanceEvent(InstanceEvent $event)
 {
     $this->eventBus->register($event->getInstance());
 }