/** * 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)); }
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; }
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; } }
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); }
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; }
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; } }
public function factory(IContext $context, IEventBus $eventBus, array $parameterList = []) { $eventBus->emit(new SingletonEvent($this->name, $this->instance)); return $this->instance; }
public function onInstanceEvent(InstanceEvent $event) { $this->eventBus->register($event->getInstance()); }