mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 17:29:04 +00:00 
			
		
		
		
	Optimized law draft
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| <?php | ||||
| namespace Entity\Attribut; | ||||
| namespace App\Entity\Attribut; | ||||
|  | ||||
| use App\Entity\RightInterface; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <?php | ||||
| namespace Entity\Attribut; | ||||
| namespace App\Entity\Attribut; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <?php | ||||
| namespace Entity\Attribut; | ||||
| namespace App\Entity\Attribut; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,7 @@ trait TypeAttribut { | ||||
|      */ | ||||
|     protected $type; | ||||
|      | ||||
|     public function setType(string $right):void{ | ||||
|     public function setType(string $type):void{ | ||||
|         $this->type = $type; | ||||
|     } | ||||
|      | ||||
|   | ||||
| @@ -8,7 +8,7 @@ namespace App\Entity\Attribut; | ||||
|  */ | ||||
| interface TypeAttributInterface | ||||
| { | ||||
|     public function setType(string $right):void; | ||||
|     public function setType(string $type):void; | ||||
|      | ||||
|     public function getType():string; | ||||
| } | ||||
|   | ||||
| @@ -2,9 +2,10 @@ | ||||
| namespace App\Entity; | ||||
|  | ||||
| use Doctrine\ORM\Mapping as ORM; | ||||
| use Entity\Attribut\RightsAttribute; | ||||
| use App\Entity\Attribut\RightsAttribute; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\DBAL\Types\RightType; | ||||
| use App\Entity\Attribut\NodeAttribut; | ||||
|  | ||||
| /** | ||||
|  * | ||||
| @@ -14,7 +15,7 @@ use App\DBAL\Types\RightType; | ||||
|  */ | ||||
| class Law extends AbstractEntity implements LawInterface | ||||
| { | ||||
|     use RightsAttribute; | ||||
|     use RightsAttribute, NodeAttribut; | ||||
|  | ||||
|     /** | ||||
|      * | ||||
| @@ -23,17 +24,25 @@ class Law extends AbstractEntity implements LawInterface | ||||
|      */ | ||||
|     protected $rights; | ||||
|  | ||||
|     /** | ||||
|      * @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"}) | ||||
|      * @ORM\JoinColumn(name="node_id", referencedColumnName="id") | ||||
|      * @var NodeInterface | ||||
|      */ | ||||
|     protected $node; | ||||
|      | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__contruct(); | ||||
|         $this->initAllRights(); | ||||
|     } | ||||
|  | ||||
|     private function initAllRights(): void | ||||
|     { | ||||
|         $this->rights = new ArrayCollection(); | ||||
|         foreach (RightType::getChoices() as $key=>$value){ | ||||
|             $right = new Right(); | ||||
|             $right->setType($value); | ||||
|             $right->setLaw($this); | ||||
|             $this->rights->set($key, $right); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
|  | ||||
| use Entity\Attribut\RightsAttributInterface; | ||||
| use App\Entity\Attribut\RightsAttributInterface; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|   | ||||
| @@ -6,16 +6,25 @@ use App\Entity\Attribut\TypeAttribut; | ||||
| use App\DBAL\Types\RightType; | ||||
| use Doctrine\ORM\Mapping as ORM; | ||||
| use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert; | ||||
| use App\Entity\Attribut\LawAttributInterface; | ||||
| use App\Entity\Attribut\LawAttribut; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  * @ORM\Table(name="right") | ||||
|  * @ORM\Table(name="`right`") | ||||
|  * @ORM\Entity(repositoryClass="App\Repository\RightRepository") | ||||
|  */ | ||||
| class Right extends AbstractEntity implements RightInterface | ||||
| { | ||||
|     use TypeAttribut; | ||||
|     use TypeAttribut,LawAttribut; | ||||
|      | ||||
|     /** | ||||
|      * @ORM\ManyToOne(targetEntity="Law",cascade={"persist", "remove"}) | ||||
|      * @ORM\JoinColumn(name="law_id", referencedColumnName="id") | ||||
|      * @var LawInterface | ||||
|      */ | ||||
|     protected $law; | ||||
|      | ||||
|     /** | ||||
|      * @ORM\Column(name="type", type="RightType", nullable=false) | ||||
|   | ||||
| @@ -3,13 +3,14 @@ namespace App\Entity; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Attribut\TypeAttributInterface; | ||||
| use App\Entity\Attribut\LawAttributInterface; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  *         | ||||
|  */ | ||||
| interface RightInterface extends TypeAttributInterface | ||||
| interface RightInterface extends TypeAttributInterface, LawAttributInterface | ||||
| { | ||||
|      | ||||
|     public function isGranted(NodeInterface $node): bool; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user