Optimized law draft

This commit is contained in:
Kevin Frantz
2018-09-13 15:55:48 +02:00
parent 5f011f632b
commit b9f483bf7f
13 changed files with 206 additions and 12 deletions

View File

@@ -1,15 +1,42 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM;
use Entity\Attribut\RightsAttribute;
use Doctrine\Common\Collections\ArrayCollection;
use App\DBAL\Types\RightType;
/**
*
* @author kevinfrantz
*
* @ORM\Table(name="law")
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
*/
class Law implements LawInterface
class Law extends AbstractEntity implements LawInterface
{
use NodeAttribut;
use RightsAttribute;
/**
*
* @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"})
* @var ArrayCollection
*/
protected $rights;
public function __construct()
{
parent::__contruct();
$this->initAllRights();
}
private function initAllRights(): void
{
foreach (RightType::getChoices() as $key=>$value){
$right = new Right();
$right->setType($value);
$this->rights->set($key, $right);
}
}
}