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 Validators::validateEntityName() #6510

Merged
merged 1 commit into from
Oct 20, 2020
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
10 changes: 10 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
UPGRADE 3.x
===========

UPGRADE FROM 3.x to 3.x
=======================

### Deprecated `Sonata\AdminBundle\Command\Validators::validateEntityName()`

In version 3.77, the shortcut notation for model class names (`AppBundle:User`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In version 3.77, the shortcut notation for model class names (`AppBundle:User`)
In version 3.x, the shortcut notation for model class names (`AppBundle:User`)

until released? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 3.77 is already released.

has been deprecated in favor of its FQCN (`App\Model\User`) when passing `user_model`
option to `sonata:admin:generate-object-acl` command, so this method SHOULD not
be called if that deprecation is addressed.

### Deprecated not configuring `acl_user_manager` and using ACL security handler when `friendsofsymfony/user-bundle` is installed.

If you are using `friendsofsymfony/user-bundle` and using ACL security handler, you MUST explicitly configure the `acl_user_manager`.
Expand Down
10 changes: 10 additions & 0 deletions src/Command/Validators.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public static function validateUsername($username)
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/admin-bundle 3.x, will be removed in version 4.0.
*
* @static
*
* @param string $shortcut
Expand All @@ -51,6 +55,12 @@ public static function validateUsername($username)
*/
public static function validateEntityName($shortcut)
{
@trigger_error(sprintf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is a testcase which needs to be marked with @legacy

'Method "%s()" is deprecated since sonata-project/admin-bundle 3.x'
.' and will be removed in version 4.0.',
__METHOD__
), E_USER_DEPRECATED);

$model = str_replace('/', '\\', $shortcut);

if (false === $pos = strpos($model, ':')) {
Expand Down
14 changes: 14 additions & 0 deletions tests/Command/ValidatorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ public function testValidateUsernameWithException(): void
}

/**
* NEXT_MAJOR: Remove this test.
*
* @group legacy
*
* @dataProvider getValidateEntityNameTests
*/
public function testValidateEntityName(array $expected, string $value): void
{
$this->assertSame($expected, Validators::validateEntityName($value));
}

/**
* NEXT_MAJOR: Remove this method.
*/
public function getValidateEntityNameTests(): array
{
return [
Expand All @@ -62,6 +69,10 @@ public function getValidateEntityNameTests(): array
}

/**
* NEXT_MAJOR: Remove this test.
*
* @group legacy
*
* @dataProvider getValidateEntityNamesWithExceptionTests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This getValidateEntityNamesWithExceptionTests() needs to be removed as well in the next major

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

*/
public function testValidateEntityNameWithException(string $value): void
Expand All @@ -71,6 +82,9 @@ public function testValidateEntityNameWithException(string $value): void
Validators::validateEntityName($value);
}

/**
* NEXT_MAJOR: Remove this method.
*/
public function getValidateEntityNamesWithExceptionTests(): array
{
return [
Expand Down