public function get() { if ($this->instance === null) { $this->instance = $this->context->create($this->getTarget(), $this->getParameterList()); } return $this->instance; }
/** * @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()))); }
/** * 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 createQuery() { $scannerQuery = $this->context->create(IScannerQuery::class); $scannerQuery->select(new AsteriskFragment()); $scannerQuery->from(new SelectTable($this->createScannerFile()->schema()->getName())); return $scannerQuery; }
/** * @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)); }
/** * @param string $name * * @return IPiccoHandler */ public function createHandler($name) { return $this->context->create($name); }
/** * @param string $name * * @return IRouter */ protected function createRouter($name) { return $this->context->create($name); }
protected function getDependencyList(IContext $context, array $parameterList) { $dependencyList = []; foreach ($this->getParameterList() as $name => $class) { $dependencyList[$name] = $context->create($class); } return array_merge($dependencyList, $parameterList); }