Skip to content

Commit

Permalink
Deprecate BCLabelTranslatorStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Sep 13, 2022
1 parent 7854513 commit a314ab2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Resources/config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

// Services used to format the label, default is sonata.admin.label.strategy.noop

// NEXT_MAJOR: Remove this line.
->set('sonata.admin.label.strategy.bc', BCLabelTranslatorStrategy::class)

->set('sonata.admin.label.strategy.native', NativeLabelTranslatorStrategy::class)
Expand Down
10 changes: 10 additions & 0 deletions src/Translator/BCLabelTranslatorStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@

/**
* @author Thomas Rabaix <[email protected]>
*
* NEXT_MAJOR: Remove this class.
*
* @deprecated since sonata-project/admin-bundle 4.x, will be removed in 5.0.
*/
final class BCLabelTranslatorStrategy implements LabelTranslatorStrategyInterface
{
public function getLabel(string $label, string $context = '', string $type = ''): string
{
@trigger_error(sprintf(
'The "%s" class is deprecated since sonata-project/admin-bundle version 4.x and will be'
.' removed in 5.0 version.',
self::class
), \E_USER_DEPRECATED);

if ('breadcrumb' === $context) {
return sprintf('%s.%s_%s', $context, $type, strtolower($label));
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Translator/BCLabelTranslatorStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
use PHPUnit\Framework\TestCase;
use Sonata\AdminBundle\Translator\BCLabelTranslatorStrategy;

/**
* NEXT_MAJOR: Remove this class.
*
* @group legacy
*/
final class BCLabelTranslatorStrategyTest extends TestCase
{
public function testLabel(): void
Expand Down

0 comments on commit a314ab2

Please sign in to comment.