mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Optimized ORM Draft
This commit is contained in:
		
							
								
								
									
										28
									
								
								application/src/Entity/Attribut/ChildsAttribut.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								application/src/Entity/Attribut/ChildsAttribut.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| <?php | ||||
| namespace App\Entity\Attribut; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| /** | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  *         | ||||
|  */ | ||||
| trait ChildsAttribut { | ||||
|      | ||||
| /** | ||||
|      * @var ArrayCollection | ||||
|      */ | ||||
|     protected $childs; | ||||
|      | ||||
|     public function getChilds(): ArrayCollection | ||||
|     { | ||||
|         return $this->getChilds(); | ||||
|     } | ||||
|      | ||||
|     public function setChilds(ArrayCollection $childs): void | ||||
|     { | ||||
|         $this->childs = $childs; | ||||
|     } | ||||
|      | ||||
| } | ||||
|  | ||||
							
								
								
									
										15
									
								
								application/src/Entity/Attribut/ChildsAttributeInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								application/src/Entity/Attribut/ChildsAttributeInterface.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| <?php | ||||
| namespace App\Entity\Attribut; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| /** | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  *         | ||||
|  */ | ||||
| interface ChildsAttributeInterface | ||||
| { | ||||
|     public function setChilds(ArrayCollection $childs):void; | ||||
|      | ||||
|     public function getChilds():ArrayCollection; | ||||
| } | ||||
|  | ||||
| @@ -12,7 +12,7 @@ trait NodeAttribut{ | ||||
|     /** | ||||
|      * @var NodeInterface | ||||
|      * @ORM\OneToOne(targetEntity="Node") | ||||
|      * @ORM\JoinColumn(name="source", referencedColumnName="id") | ||||
|      * @ORM\JoinColumn(name="node_id", referencedColumnName="id") | ||||
|      */ | ||||
|     protected $node; | ||||
|      | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| namespace App\Entity\Attribut; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\NodeInterface; | ||||
|  | ||||
| /** | ||||
|  * | ||||
| @@ -10,9 +9,9 @@ use App\Entity\NodeInterface; | ||||
|  *         | ||||
|  */ | ||||
| trait ParentAttribut { | ||||
|      | ||||
|     /** | ||||
|      * | ||||
|      * @var ArrayCollection|NodeInterface[] | ||||
|      * @var ArrayCollection | ||||
|      */ | ||||
|     protected $parents; | ||||
|      | ||||
|   | ||||
| @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Attribut\IdAttribut; | ||||
| use App\Entity\Attribut\SourceAttribut; | ||||
| use App\Entity\Attribut\ParentAttribut; | ||||
| use App\Entity\Attribut\ChildsAttribut; | ||||
|  | ||||
| /** | ||||
|  * | ||||
| @@ -15,18 +16,28 @@ use App\Entity\Attribut\ParentAttribut; | ||||
|  */ | ||||
| class Node implements NodeInterface | ||||
| { | ||||
|     use IdAttribut,SourceAttribut, ParentAttribut; | ||||
|     use IdAttribut,SourceAttribut, ParentAttribut, ChildsAttribut; | ||||
|      | ||||
|     /** | ||||
|      *  | ||||
|      * Many Nodes have many parents | ||||
|      * @ORM\ManyToMany(targetEntity="Node") | ||||
|      * @ORM\JoinTable(name="nodes_parents", | ||||
|      *      joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, | ||||
|      *      inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} | ||||
|      *      ) | ||||
|      * @var ArrayCollection|Node[] | ||||
|      */ | ||||
|     protected $parents; | ||||
|      | ||||
|     /** | ||||
|      * Many Nodes have many childs | ||||
|      * @ORM\ManyToMany(targetEntity="Node") | ||||
|      * @ORM\JoinTable(name="nodes_childs", | ||||
|      *      joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}, | ||||
|      *      inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")} | ||||
|      *      ) | ||||
|      * @var ArrayCollection|Node[] | ||||
|      */ | ||||
|     protected $childs; | ||||
|  | ||||
|     public function getChilds(): ArrayCollection | ||||
|     {} | ||||
|  | ||||
|     public function setChilds(ArrayCollection $childs): void | ||||
|     {} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,20 +1,16 @@ | ||||
| <?php | ||||
| namespace App\Entity; | ||||
|  | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Attribut\SourceAttributInterface; | ||||
| use App\Entity\Attribut\IdAttributInterface; | ||||
| use App\Entity\Attribut\ParentsAttributInterface; | ||||
| use App\Entity\Attribut\ChildsAttributeInterface; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  *         | ||||
|  */ | ||||
| interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface | ||||
| {    | ||||
|     public function setChilds(ArrayCollection $childs):void; | ||||
|      | ||||
|     public function getChilds():ArrayCollection; | ||||
| } | ||||
| interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface,ChildsAttributeInterface | ||||
| {} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user