Phprest\Application::__construct PHP Метод

__construct() публичный Метод

public __construct ( Config $configuration )
$configuration Config
    public function __construct(Config $configuration)
    {
        $this->configuration = $configuration;
        $this->container = $configuration->getContainer();
        $this->router = $configuration->getRouter();
        $this->emitter = $configuration->getEventEmitter();
        AnnotationRegistry::registerLoader('class_exists');
        $this->registerService($configuration->getHateoasService(), $configuration->getHateoasConfig());
        $this->registerService($configuration->getLoggerService(), $configuration->getLoggerConfig());
        $this->setErrorHandler();
        $this->container->add(self::CONTAINER_ID_VENDOR, $configuration->getVendor());
        $this->container->add(self::CONTAINER_ID_API_VERSION, $configuration->getApiVersion());
        $this->container->add(self::CONTAINER_ID_DEBUG, $configuration->isDebug());
        $this->container->add(self::CONTAINER_ID_ROUTER, function () {
            return $this->router;
        });
        $this->stackBuilder = new Stack\Builder();
    }

Usage Example

Пример #1
0
 /**
  * Create a new Streamlines application instance.
  *
  * @param  \Phprest\Config  $phprestConfig
  * @param  string|null  $basePath
  */
 public function __construct(PhprestConfig $phprestConfig, $basePath = null)
 {
     parent::__construct($phprestConfig);
     if ($basePath !== null) {
         $this->setBasePath($basePath);
     }
     $this->config = new Config($this->configPath());
 }