mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-03 18:58:01 +00:00 
			
		
		
		
	In between commit implementing reciever
This commit is contained in:
		
							
								
								
									
										54
									
								
								application/src/Entity/Attribut/MembersAttribut.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								application/src/Entity/Attribut/MembersAttribut.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Attribut;
 | 
			
		||||
 | 
			
		||||
use Doctrine\Common\Collections\Collection;
 | 
			
		||||
use Doctrine\Common\Collections\ArrayCollection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
trait MembersAttribut
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Collection
 | 
			
		||||
     */
 | 
			
		||||
    protected $members;
 | 
			
		||||
 | 
			
		||||
    public function getMembers(): Collection
 | 
			
		||||
    {
 | 
			
		||||
        return $this->members;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setMembers(Collection $members): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->members = $members;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param int        $dimension The dimensions start with 1 for the members of the actuall dimension and NULL for all members
 | 
			
		||||
     * @param Collection $members   A reference to a members list, to which new members should be add
 | 
			
		||||
     *
 | 
			
		||||
     * @return Collection|MembersAttributInterface[] Returns all members till the defined dimension
 | 
			
		||||
     */
 | 
			
		||||
    public function getMembersInclusiveChildren(int $dimension = null, Collection &$members = null): Collection
 | 
			
		||||
    {
 | 
			
		||||
        // Subtract minus one, so that following members start on a other dimension:
 | 
			
		||||
        --$dimension;
 | 
			
		||||
 | 
			
		||||
        //Define members if no members are passed
 | 
			
		||||
        if (!$members) {
 | 
			
		||||
            $members = new ArrayCollection();
 | 
			
		||||
        }
 | 
			
		||||
        foreach ($this->members as $member) {
 | 
			
		||||
            if (!$members->contains($member)) {
 | 
			
		||||
                $members->add($member);
 | 
			
		||||
                if ($dimension > 0 || null === $dimension) {
 | 
			
		||||
                    $member->getMembersInclusiveChildren($dimension, $members);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $members;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Source\Attribut;
 | 
			
		||||
namespace App\Entity\Attribut;
 | 
			
		||||
 | 
			
		||||
use Doctrine\Common\Collections\Collection;
 | 
			
		||||
 | 
			
		||||
@@ -20,4 +20,9 @@ interface MembersAttributInterface
 | 
			
		||||
     * @return Collection
 | 
			
		||||
     */
 | 
			
		||||
    public function getMembers(): Collection;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return Collection
 | 
			
		||||
     */
 | 
			
		||||
    public function getMembersInclusiveChildren(int $dimension = null): Collection;
 | 
			
		||||
}
 | 
			
		||||
@@ -4,9 +4,9 @@ namespace App\Entity\Meta;
 | 
			
		||||
 | 
			
		||||
use Doctrine\Common\Collections\ArrayCollection;
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
 | 
			
		||||
use App\Entity\Attribut\RelationAttribut;
 | 
			
		||||
use App\Entity\Attribut\RelationAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\MembersAttribut;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -15,7 +15,7 @@ use App\Entity\Attribut\RelationAttributInterface;
 | 
			
		||||
 */
 | 
			
		||||
class Reciever extends AbstractMeta implements RecieverInterface
 | 
			
		||||
{
 | 
			
		||||
    use RelationAttribut;
 | 
			
		||||
    use RelationAttribut, MembersAttribut;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The node for which the right exists.
 | 
			
		||||
@@ -29,6 +29,7 @@ class Reciever extends AbstractMeta implements RecieverInterface
 | 
			
		||||
 | 
			
		||||
    public function getAllRecievers(): ArrayCollection
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->members->getValues() as $source) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,12 @@ namespace App\Entity\Meta;
 | 
			
		||||
 | 
			
		||||
use Doctrine\Common\Collections\ArrayCollection;
 | 
			
		||||
use App\Entity\Attribut\RelationAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\MembersAttributInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface RecieverInterface extends RelationAttributInterface, MetaInterface
 | 
			
		||||
interface RecieverInterface extends RelationAttributInterface, MetaInterface, MembersAttributInterface
 | 
			
		||||
{
 | 
			
		||||
    public function getAllRecievers(): ArrayCollection;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,26 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Source\Attribut;
 | 
			
		||||
 | 
			
		||||
use Doctrine\Common\Collections\Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
trait MembersAttribut
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Collection
 | 
			
		||||
     */
 | 
			
		||||
    protected $members;
 | 
			
		||||
 | 
			
		||||
    public function getMembers(): Collection
 | 
			
		||||
    {
 | 
			
		||||
        return $this->members;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setMembers(Collection $members): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->members = $members;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,8 +4,8 @@ namespace App\Entity\Source;
 | 
			
		||||
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use Doctrine\Common\Collections\Collection;
 | 
			
		||||
use App\Entity\Source\Attribut\MembersAttributInterface;
 | 
			
		||||
use App\Entity\Source\Attribut\MembersAttribut;
 | 
			
		||||
use App\Entity\Attribut\MembersAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\MembersAttribut;
 | 
			
		||||
use Doctrine\Common\Collections\ArrayCollection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Entity\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\Attribut\MembersAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\MembersAttributInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user