-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AdminBundle] Symfony 5 role incompatibility fix
- Loading branch information
Showing
5 changed files
with
103 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\AdminBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* @final | ||
* | ||
* @internal | ||
*/ | ||
trait RolePropertiesTrait | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer", name="id") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
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) | ||
{ | ||
$this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters