From d1b72a258e0828c1cadda03162f88ee4e3a1f36b Mon Sep 17 00:00:00 2001 From: "@fenric" Date: Tue, 11 Feb 2020 13:06:51 +0300 Subject: [PATCH] new release --- config/definitions/twig.php | 24 --------------------- src/Exception/InvalidEntityException.php | 2 ++ src/Exception/ResourceNotFoundException.php | 16 ++++++++++++++ src/Middleware/CorsMiddleware.php | 6 ++---- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/config/definitions/twig.php b/config/definitions/twig.php index 2233ace..65821a9 100644 --- a/config/definitions/twig.php +++ b/config/definitions/twig.php @@ -27,39 +27,15 @@ 'optimizations' => get('twig.configuration.optimizations'), ], - // A path or an array of paths where to look for templates. 'twig.configuration.loader_paths' => [ string('{app.root}/resources/views'), ], - // When set to true, it automatically set "auto_reload" to true as well (default to false). 'twig.configuration.debug' => false, - - // The charset used by the templates (default to UTF-8). 'twig.configuration.charset' => 'UTF-8', - - // Whether to ignore invalid variables in templates (default to false). 'twig.configuration.strict_variables' => false, - - // Whether to enable auto-escaping (default to html): - // * false: disable auto-escaping - // * html, js: set the autoescaping to one of the supported strategies - // * name: set the autoescaping strategy based on the template name extension - // * PHP callback: a PHP callback that returns an escaping strategy based on the template "name" 'twig.configuration.autoescape' => 'html', - - // An absolute path where to store the compiled templates, - // a \Twig\Cache\CacheInterface implementation, - // or false to disable compilation cache (default). 'twig.configuration.cache' => false, - - // Whether to reload the template if the original source changed. - // If you don't provide the auto_reload option, it will be - // determined automatically based on the debug value. 'twig.configuration.auto_reload' => null, - - // A flag that indicates which optimizations to apply - // (default to -1 which means that all optimizations are enabled; - // set it to 0 to disable). 'twig.configuration.optimizations' => -1, ]; diff --git a/src/Exception/InvalidEntityException.php b/src/Exception/InvalidEntityException.php index d049dd8..9c0d053 100644 --- a/src/Exception/InvalidEntityException.php +++ b/src/Exception/InvalidEntityException.php @@ -75,6 +75,8 @@ public function getEntityViolations() : ConstraintViolationListInterface * @param ValidatorInterface $validator * * @return void + * + * @throws self */ public static function assert(object $entity, ValidatorInterface $validator) : void { diff --git a/src/Exception/ResourceNotFoundException.php b/src/Exception/ResourceNotFoundException.php index 9ab3d1e..c9d6cb9 100644 --- a/src/Exception/ResourceNotFoundException.php +++ b/src/Exception/ResourceNotFoundException.php @@ -17,4 +17,20 @@ public function __construct(string $message = null) { parent::__construct($message ?? 'The requested resource was not found'); } + + /** + * Throws the exception if the given entity is NULL + * + * @param null|object $entity + * + * @return void + * + * @throws self + */ + public static function assert(?object $entity) : void + { + if (null === $entity) { + throw new self($entity, $violations); + } + } } diff --git a/src/Middleware/CorsMiddleware.php b/src/Middleware/CorsMiddleware.php index 644e749..bdb78f8 100644 --- a/src/Middleware/CorsMiddleware.php +++ b/src/Middleware/CorsMiddleware.php @@ -37,11 +37,9 @@ final class CorsMiddleware implements MiddlewareInterface */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { - $settings = $this->createSettings( + $analyzer = Analyzer::instance($this->createSettings( $this->container->get('cors.configuration') - ); - - $analyzer = Analyzer::instance($settings); + )); if ($this->container->get('cors.debug')) { $analyzer->setLogger($this->container->get('logger'));