Skip to content

Commit

Permalink
Deprecate getUrlsafeIdentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jul 19, 2021
1 parent 9cf2b0f commit ee10047
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Extension/TemplateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

/**
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/twig-extensions 1.7, to be removed in 2.0.
*/
final class TemplateExtension extends AbstractExtension
{
/**
Expand Down Expand Up @@ -59,6 +64,13 @@ public function getTokenParsers(): array
*/
public function getUrlsafeIdentifier($model): ?string
{
@trigger_error(sprintf(
'Method "%s()" is deprecated since sonata-project/twig-extension 1.7 and will be removed in version 2.0'
.' in favor of the "sonata_urlsafeid" method of the SonataAdminBundle.'
.' You might solve this deprecation by declaring this bundle before the SonataAdminBundle one.',
__METHOD__
), \E_USER_DEPRECATED);

return $this->modelAdapter->getUrlsafeIdentifier($model);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Extension/TemplateExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
use Sonata\Doctrine\Adapter\AdapterInterface;
use Sonata\Twig\Extension\TemplateExtension;

/**
* NEXT_MAJOR: Remove this class.
*/
class TemplateExtensionTest extends TestCase
{
/**
* @group legacy
*/
public function testSafeUrl(): void
{
$adapter = $this->createMock(AdapterInterface::class);
Expand Down

0 comments on commit ee10047

Please sign in to comment.