diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md new file mode 100644 index 0000000000..ce83ced0bf --- /dev/null +++ b/UPGRADE-6.1.md @@ -0,0 +1,7 @@ +AdminBundle +----------- + +* The `Kunstmaan\AdminBundle\Entity\Role` class doesn't exents from the deprecated `Symfony\Component\Security\Core\Role\Role` + class if you run your code on symfony 5. The Role class was deprecated and removed in symfony 5. If you used this class + to check the `Role` entity change it to the `Kunstmaan\AdminBundle\Entity\Role` class. + The `Role` entity won't change if you run on symfony 3.4 but it's adviced to make this change already. diff --git a/src/Kunstmaan/AdminBundle/Entity/Role.php b/src/Kunstmaan/AdminBundle/Entity/Role.php index 0a01cba131..6bba8bd9df 100644 --- a/src/Kunstmaan/AdminBundle/Entity/Role.php +++ b/src/Kunstmaan/AdminBundle/Entity/Role.php @@ -5,77 +5,26 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\Role\Role as BaseRole; -use Symfony\Component\Validator\Constraints as Assert; -/** - * @ORM\Entity - * @ORM\Table( name="kuma_roles" ) - * @UniqueEntity("role") - */ -class Role extends BaseRole -{ +// NEXT_MAJOR Remove the RolePropertiesTrait when symfony 4 support is removed +if (class_exists(BaseRole::class)) { /** - * @ORM\Id - * @ORM\Column(type="integer", name="id") - * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\Entity + * @ORM\Table( name="kuma_roles" ) + * @UniqueEntity("role") */ - protected $id; - - /** - * @Assert\NotBlank() - * @ORM\Column(type="string", name="role", unique=true, length=70) - */ - protected $role; - - /** - * Populate the role field - * - * @param string $role - */ - public function __construct($role) + class Role extends BaseRole { - $this->role = $role; + use RolePropertiesTrait; } - - /** - * Return the role field. - * - * @return string - */ - public function getRole() - { - return $this->role; - } - +} else { /** - * Return the string representation of the role entity. + * @ORM\Entity + * @ORM\Table( name="kuma_roles" ) + * @UniqueEntity("role") */ - public function __toString(): string + class Role { - return (string) $this->role; - } - - /** - * Get id - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Modify the role field. - * - * @param string $role ROLE_FOO etc - * - * @return RoleInterface - */ - public function setRole($role) - { - $this->role = $role; - - return $this; + use RolePropertiesTrait; } } diff --git a/src/Kunstmaan/AdminBundle/Entity/RolePropertiesTrait.php b/src/Kunstmaan/AdminBundle/Entity/RolePropertiesTrait.php new file mode 100644 index 0000000000..14ee864181 --- /dev/null +++ b/src/Kunstmaan/AdminBundle/Entity/RolePropertiesTrait.php @@ -0,0 +1,79 @@ +role = $role; + } + + /** + * Return the role field. + * + * @return string + */ + public function getRole() + { + return $this->role; + } + + /** + * Return the string representation of the role entity. + */ + public function __toString(): string + { + return (string) $this->role; + } + + /** + * Get id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Modify the role field. + * + * @param string $role ROLE_FOO etc + * + * @return Role + */ + public function setRole($role) + { + $this->role = $role; + + return $this; + } +} diff --git a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php index 99a36201d0..4151d48c4a 100644 --- a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php +++ b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php @@ -155,9 +155,11 @@ public function getPermissions() */ public function getPermission($role) { - if ($role instanceof \Symfony\Component\Security\Core\Role\Role) { + // NEXT_MAJOR remove undefined classes from this check + if ($role instanceof \Symfony\Component\Security\Core\Role\Role || $role instanceof Role) { $role = $role->getRole(); } + if (isset($this->permissions[$role])) { return $this->permissions[$role]; } diff --git a/src/Kunstmaan/AdminBundle/composer.json b/src/Kunstmaan/AdminBundle/composer.json index 1595cac600..cf0993c9eb 100644 --- a/src/Kunstmaan/AdminBundle/composer.json +++ b/src/Kunstmaan/AdminBundle/composer.json @@ -27,7 +27,7 @@ "symfony/cache": "^4.4|^5.3", "symfony/config": "^4.4|^5.3", "symfony/console": "^4.4|^5.3", - "symfony/dependency-injection": "^4.4v", + "symfony/dependency-injection": "^4.4|^5.3", "symfony/dom-crawler": "^4.4|^5.3", "symfony/event-dispatcher": "^4.4|^5.3", "symfony/filesystem": "^4.4|^5.3",