/** * @param Config $config */ protected function setContainerElements(Config $config) { AnnotationRegistry::registerLoader('class_exists'); $config->getHateoasService()->register($config->getContainer(), $config->getHateoasConfig()); $config->getContainer()->add(Application::CONTAINER_ID_VENDOR, $config->getVendor()); $config->getContainer()->add(Application::CONTAINER_ID_API_VERSION, $config->getApiVersion()); $config->getContainer()->add(Application::CONTAINER_ID_DEBUG, $config->isDebug()); }
public function appProvider() { $app = \Mockery::mock('Phprest\\Application'); $config = new Config('test', '2.6'); $config->getContainer()->add(Application::CONTAINER_ID_VENDOR, $config->getVendor()); $config->getContainer()->add(Application::CONTAINER_ID_API_VERSION, $config->getApiVersion()); $config->getContainer()->add(Application::CONTAINER_ID_DEBUG, $config->isDebug()); $app->shouldReceive('getConfiguration')->andReturn($config); $app->shouldReceive('getContainer')->andReturn($config->getContainer()); return [[$app]]; }
public function testGetters() { $config = new Config('phprest', 1, true); $this->assertEquals('phprest', $config->getVendor()); $this->assertEquals(1, $config->getApiVersion()); $this->assertEquals(true, $config->isDebug()); $this->assertInstanceOf('\\League\\Container\\Container', $config->getContainer()); $this->assertInstanceOf('\\League\\Route\\RouteCollection', $config->getRouter()); $this->assertInstanceOf('\\League\\Event\\Emitter', $config->getEventEmitter()); $this->assertInstanceOf('\\Phprest\\Service\\Hateoas\\Config', $config->getHateoasConfig()); $this->assertInstanceOf('\\Phprest\\Service\\Hateoas\\Service', $config->getHateoasService()); $this->assertInstanceOf('\\League\\BooBoo\\Runner', $config->getErrorHandler()); $this->assertInstanceOf('\\Phprest\\ErrorHandler\\Handler\\Log', $config->getLogHandler()); }
/** * @param Config $configuration */ 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(); }
/** * @return \League\Container\ContainerInterface */ protected function getContainer() { return $this->config->getContainer(); }