isDebug() public méthode

public isDebug ( ) : boolean
Résultat boolean
Exemple #1
0
 /**
  * @param \Exception $exception
  *
  * @return string
  */
 public function format(\Exception $exception)
 {
     $response = new Response();
     try {
         $response = $this->serialize($this->config->isDebug() ? new Entity\DebugError($exception) : new Entity\Error($exception), is_null($this->request) ? Request::createFromGlobals() : $this->request, $response);
     } catch (\Exception $e) {
         $response->setContent($this->serviceHateoas()->getSerializer()->serialize($this->config->isDebug() ? new Entity\DebugError($e) : new Entity\Error($e), 'json'));
         $vendor = $this->getContainer()->get(Application::CONTAINER_ID_VENDOR);
         $apiVersion = $this->getContainer()->get(Application::CONTAINER_ID_API_VERSION);
         $response->headers->set('Content-Type', 'application/vnd.' . $vendor . '-v' . $apiVersion . '+json');
     }
     $response->setStatusCode(method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : 500);
     $response->sendHeaders();
     return $response->getContent();
 }
Exemple #2
0
 /**
  * @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());
 }
Exemple #3
0
 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]];
 }
Exemple #4
0
 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());
 }
Exemple #5
0
 /**
  * @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();
 }