sf4 deprecated: migrate Doctrine ORM mapping to annotation

This commit is contained in:
2020-07-24 14:51:34 +02:00
parent 3033be78d2
commit 2746d3e003
20 changed files with 434 additions and 410 deletions

View File

@@ -20,72 +20,103 @@
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Chill\MainBundle\Entity\RoleScope;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
*
* @ORM\Entity()
* @ORM\Table(name="permission_groups")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class PermissionsGroup
{
/**
* @var integer
*
* @var int
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
*
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
*
* @var string[]
*
* @ORM\Column(type="json")
*/
private $flags = [];
/**
* @var Collection
*
* @var \Doctrine\Common\Collections\Collection
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\RoleScope",
* inversedBy="permissionsGroups",
* cascade={ "persist" })
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private $roleScopes;
/**
* @var Collection
*
* @var \Doctrine\Common\Collections\Collection
* @ORM\OneToMany(
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
* mappedBy="permissionsGroup"
* )
*/
private $groupCenters;
/**
* PermissionsGroup constructor.
*/
public function __construct()
{
$this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return ArrayCollection|Collection
*/
public function getRoleScopes()
{
return $this->roleScopes;
}
/**
* @param $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
@@ -93,7 +124,6 @@ class PermissionsGroup
}
/**
*
* @param RoleScope $roleScope
*/
public function addRoleScope(RoleScope $roleScope)
@@ -102,7 +132,6 @@ class PermissionsGroup
}
/**
*
* @param RoleScope $roleScope
* @throws \RuntimeException if the roleScope could not be removed.
*/
@@ -115,21 +144,28 @@ class PermissionsGroup
}
}
/**
* @return string[]
*/
public function getFlags()
{
return $this->flags;
}
/**
* @param array $flags
* @return $this
*/
public function setFlags(array $flags)
{
$this->flags = $flags;
return $this;
}
/**
* Test that a role scope is associated only once with the permission group
* Test that a role scope is associated only once
* with the permission group
*
* @param ExecutionContextInterface $context
*/
@@ -150,5 +186,4 @@ class PermissionsGroup
}
}
}