/** * {@inheritdoc} */ public function execute(ContainerInterface $app) { foreach ($this->commands as $command) { $this->console->add($app->create($command)); } $this->console->run(); }
/** * {@inheritdoc} */ public function create($className) { if (!class_exists($className)) { throw new HandlerNotFoundException($className); } return $this->container->create($className); }
public function up() { require $this->fileInfo->__toString(); $migrationName = $this->getName(); $this->container->create($migrationName)->up(); $this->adapter->initialize(); $this->adapter->up($this->getId(), file_get_contents($this->fileInfo)); }
/** * @param string $migrationId */ public function down($migrationId) { if (!preg_match('/^\\d{6}_\\d{6}$/', $migrationId)) { throw new RuntimeException("invalid migration id. it must be like 000000_000000."); } $version = $this->adapter->version($migrationId); if (!$version) { throw new RuntimeException("this {$migrationId} is not already applied."); } $migrationName = $this->getMigrationClassFromSource($version['source']); $this->container->create($migrationName)->down(); $this->adapter->down($migrationId); }
/** * {@inheritdoc} */ public function execute(ContainerInterface $app) { // @todo remove ErrorHandlerProvider // @todo add Error handler, and Whoops pretty when debug === true in Error Handler. $request = $app->get(ServerRequestFactory::class)->fromGlobals(); try { $response = $this->dispatch($app->get('router'), $request); $app->get(ResponseSender::class)->sendToGlobal($response); } catch (Exception $exception) { if ($exception instanceof HttpException) { $httpException = $exception; } else { // if not HttpException and debug mode, exception will be prettify(by Whoops). if ($app['config']->get('debug', true)) { throw $exception; } $httpException = new HttpException(); } $handler = $app['config']->get('error.handler'); if ($handler) { $response = $this->responsify($app->create($handler)->handle($request, $exception), $httpException); } else { $response = $httpException->toResponse(); } // body is '' if (!$response->getBody()) { $body = $response->getReasonPhrase(); $response = $response->withBody(new Stringstream($body)); } $app->get(ResponseSender::class)->sendToGlobal($response); } }
/** * {@inheritdoc} */ public function boot(ContainerInterface $app) { $app->instance(Config::class, new Config($this->definition->configs())); $app->alias(ConfigInterface::class, Config::class); $app->alias('config', Config::class); foreach ($this->definition->providers() as $provider) { $app->register($app->create($provider)); } $this->app = $app; }
public function execute(ContainerInterface $app) { try { $app->inject($this->test); } catch (CannotInjectException $exception) { $propertyName = $exception->getProperty(); $className = $exception->getClass(); if (class_exists($className)) { $app->inject($this->test, [$propertyName => $app->create($className)]); } else { throw $exception; } } }