Skip to content

Commit

Permalink
Deprecate CmsRouter toString method for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
javihgil committed Jul 3, 2024
1 parent be89569 commit a7d2673
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Routing/CmsRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ 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);
$parameters = array_map(function ($value) {
if (is_object($value) && method_exists($value, '__toString')) {
trigger_error('Using objects with __toString as parameters is deprecated since softspring/cms-bundle 5.2 and will be removed in 6.0. Use the specific id field.', E_USER_DEPRECATED);
}

return $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 a7d2673

Please sign in to comment.