Abstract actor model has more straightforward API
The implicit API requirements via class properties has been changed to relay now on abstract methods that the extending class must implement.
This commit is contained in:
@@ -3,13 +3,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Tests\Ressources\TestModels;
|
||||
|
||||
use Generator;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\Table;
|
||||
|
||||
use Lotgd\Core\Models\Actor;
|
||||
#use LotGD\Core\Models\PermissionableInterface;
|
||||
#use LotGD\Core\Tools\Model\Permissionable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,8 +18,6 @@ use Lotgd\Core\Models\Actor;
|
||||
*/
|
||||
class User extends Actor #implements PermissionableInterface {
|
||||
{
|
||||
#use Permissionable;
|
||||
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
private $id;
|
||||
/** @Column(type="string", length=50); */
|
||||
@@ -27,8 +25,6 @@ class User extends Actor #implements PermissionableInterface {
|
||||
/** @OneToMany(targetEntity="UserPermissionAssociation", mappedBy="owner", cascade={"persist", "remove"}, orphanRemoval=true) */
|
||||
protected $permissions;
|
||||
|
||||
protected $permissionAssociationEntity = UserPermissionAssociation::class;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->permissions = new ArrayCollection();
|
||||
@@ -53,4 +49,16 @@ class User extends Actor #implements PermissionableInterface {
|
||||
{
|
||||
return "User #".$this->id." (".$this->name.")";
|
||||
}
|
||||
|
||||
protected function getPermissionAssociationClass(): string
|
||||
{
|
||||
return UserPermissionAssociation::class;
|
||||
}
|
||||
|
||||
protected function getPermissionAssociations(): Generator
|
||||
{
|
||||
foreach ($this->permissions as $permission) {
|
||||
yield $permission;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user