Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate BCLabelTranslatorStrategy #7927

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADE-4.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
UPGRADE 4.x
===========

UPGRADE FROM 4.18 to 4.19
=========================

## BCLabelTranslatorStrategy

The BCLabelTranslatorStrategy is deprecated. Please use another label translator strategy or
implements your own directly in your project.

UPGRADE FROM 4.13 to 4.14
=========================

Expand Down
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