Skip to content

Commit

Permalink
Fix routing generation with doctrine proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
javihgil committed Jul 2, 2024
1 parent 292d5a1 commit 39e378e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Routing/CmsRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Softspring\CmsBundle\Routing;

use Doctrine\Persistence\Proxy;
use Exception;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
Expand Down Expand Up @@ -47,6 +48,9 @@ public function getRouteCollection(): RouteCollection

public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
// prevent error with symfony/router >= 5.4 and doctrine proxies
$parameters = array_map(fn ($value) => $value instanceof Proxy && method_exists($value, '__toString') ? $value->__toString() : $value, $parameters);

try {
$cleanParams = array_filter($parameters, fn ($key) => !in_array($key, ['_sfs_cms_locale', '_sfs_cms_locale_path']), ARRAY_FILTER_USE_KEY);

Expand Down

0 comments on commit 39e378e

Please sign in to comment.