In between commit implementing reciever

This commit is contained in:
Kevin Frantz
2018-10-31 17:19:10 +01:00
parent bb01080b34
commit e7f82c4835
8 changed files with 77 additions and 40 deletions

View 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;
}
}