Пример #1
0
 public function get()
 {
     if ($this->instance === null) {
         $this->instance = $this->context->create($this->getTarget(), $this->getParameterList());
     }
     return $this->instance;
 }
Пример #2
0
 /**
  * @return IPresenter
  */
 public function factory()
 {
     $modulePath = [];
     foreach ($this->request->getModulePath() as $module) {
         $modulePath[] = StringUtils::camelize($module) . 'Module';
     }
     return $this->context->create(sprintf('%s\\%sPresenter', implode('\\', $modulePath), StringUtils::camelize($this->request->getPresenter())));
 }
Пример #3
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));
 }
Пример #4
0
 public function createQuery()
 {
     $scannerQuery = $this->context->create(IScannerQuery::class);
     $scannerQuery->select(new AsteriskFragment());
     $scannerQuery->from(new SelectTable($this->createScannerFile()->schema()->getName()));
     return $scannerQuery;
 }
Пример #5
0
 /**
  * @param callable[] $listenerList
  *
  * @return IContext
  */
 public static function bootstrap(callable ...$listenerList)
 {
     self::listener(...$listenerList);
     $eventBus = self::$context->create(IEventBus::class);
     /**
      * prepare core system; this is time to prepare context for IConfiguration creation
      */
     $eventBus->emit(new BootEvent(self::$context));
     /**
      * bare configuration is available, now its time to add configuration files (but nothing is not configured yet)
      */
     $eventBus->emit(new ConfigurationEvent(self::$context, $configuration = self::$context->create(IConfiguration::class)));
     /**
      * full configuration is loaded and available, its time to configure individual services (but do not execute other services which
      * may not be available/configured yet)
      */
     $eventBus->emit(new SetupEvent(self::$context, $configuration));
     /**
      * everything is now configured, you can do everything here (but again: you cannot rely on the order of StartupEvent execution!)
      */
     $eventBus->emit(new StartupEvent(self::$context, $configuration));
 }
Пример #6
0
 /**
  * @param string $name
  *
  * @return IPiccoHandler
  */
 public function createHandler($name)
 {
     return $this->context->create($name);
 }
Пример #7
0
 /**
  * @param string $name
  *
  * @return IRouter
  */
 protected function createRouter($name)
 {
     return $this->context->create($name);
 }
Пример #8
0
 public function __construct(IContext $context, ICacheStorage $cacheStorage, Configuration $configuration)
 {
     $this->context = $context;
     $this->cache = new Cache($cacheStorage, static::class);
     $this->context->register(new SingletonFactory($this, IStorage::class));
 }
Пример #9
0
 protected function getDependencyList(IContext $context, array $parameterList)
 {
     $dependencyList = [];
     foreach ($this->getParameterList() as $name => $class) {
         $dependencyList[$name] = $context->create($class);
     }
     return array_merge($dependencyList, $parameterList);
 }