mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Added SourceMemberInformation
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
final class SourceMemberInformation implements SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $members;
|
||||
|
||||
public function __construct(SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
private function itterateOverMembers(Collection $members): void
|
||||
{
|
||||
foreach ($members as $member) {
|
||||
if (!$this->members->contains($member)) {
|
||||
$this->members->add($member);
|
||||
$this->itterateOverMembers($member->getMemberRelation()->getMembers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllMembers(): Collection
|
||||
{
|
||||
$this->members = new ArrayCollection();
|
||||
$this->itterateOverMembers($this->source->getMemberRelation()->getMembers());
|
||||
|
||||
return $this->members;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMemberInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] All Members which belong to a source
|
||||
*/
|
||||
public function getAllMembers(): Collection;
|
||||
}
|
@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class SourceMembershipInformation implements SourceMembershipInformationInterface
|
||||
final class SourceMembershipInformation implements SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
@@ -14,7 +14,7 @@ class SourceMembershipInformation implements SourceMembershipInformationInterfac
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
* @var Collection|SourceInterface[]
|
||||
*/
|
||||
private $memberships;
|
||||
|
||||
|
@@ -3,8 +3,12 @@
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
interface SourceMembershipInformationInterface
|
||||
{
|
||||
/**
|
||||
* @return Collection|SourceInterface[] all Sources which a Source belongs to
|
||||
*/
|
||||
public function getAllMemberships(): Collection;
|
||||
}
|
||||
|
Reference in New Issue
Block a user