Skip to content

Commit

Permalink
IBX-6504: Applied review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Oct 23, 2023
1 parent 1de9753 commit 791b764
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ services:
class: eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RoutingExtension
arguments: ["@ezpublish.route_reference.generator", "@router"]
tags:
- { name: twig.extension }
- { name: 'monolog.logger', channel: 'ibexa.core' }
- {name: twig.extension}

eZ\Publish\Core\MVC\Symfony\Templating\Twig\ResourceProvider:
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,16 @@
use eZ\Publish\Core\MVC\Symfony\Routing\Generator\RouteReferenceGeneratorInterface;
use eZ\Publish\Core\MVC\Symfony\Routing\RouteReference;
use eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Throwable;
use Twig\Extension\AbstractExtension;
use Twig\Node\Expression\ArrayExpression;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Node;
use Twig\TwigFunction;

class RoutingExtension extends AbstractExtension implements LoggerAwareInterface
class RoutingExtension extends AbstractExtension
{
use LoggerAwareTrait;

/** @var \eZ\Publish\Core\MVC\Symfony\Routing\Generator\RouteReferenceGeneratorInterface */
private $routeReferenceGenerator;

Expand All @@ -40,12 +33,10 @@ class RoutingExtension extends AbstractExtension implements LoggerAwareInterface

public function __construct(
RouteReferenceGeneratorInterface $routeReferenceGenerator,
UrlGeneratorInterface $urlGenerator,
?LoggerInterface $logger = null
UrlGeneratorInterface $urlGenerator
) {
$this->routeReferenceGenerator = $routeReferenceGenerator;
$this->urlGenerator = $urlGenerator;
$this->logger = $logger ?? new NullLogger();
}

public function getFunctions(): array
Expand Down Expand Up @@ -103,13 +94,6 @@ private function tryGeneratingUrlForObject(object $object, array $parameters, in
try {
return $this->generateUrlForObject($object, $parameters, $referenceType);
} catch (NotFoundException $e) {
return '';
} catch (Throwable $e) {
$this->logger->warning(
'Url could not be generated.',
['exception' => $e]
);

return '';
}
}
Expand Down

0 comments on commit 791b764

Please sign in to comment.