mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Solved bug in SourceMemberInformation
This commit is contained in:
parent
25ed71221d
commit
f77b5ae9a4
@ -83,12 +83,8 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
|
|||||||
private function memberExist(RightInterface $right, SourceInterface $recieverSource): bool
|
private function memberExist(RightInterface $right, SourceInterface $recieverSource): bool
|
||||||
{
|
{
|
||||||
$rightMemberInformation = new SourceMemberInformation($right->getReciever());
|
$rightMemberInformation = new SourceMemberInformation($right->getReciever());
|
||||||
// $rightMemberSources = $rightMemberInformation->getAllMembers();
|
$rightMemberSources = $rightMemberInformation->getAllMembers();
|
||||||
$rightMemberSources = new ArrayCollection();
|
|
||||||
foreach ($rightMemberSources as $memberSource) {
|
foreach ($rightMemberSources as $memberSource) {
|
||||||
// var_dump($memberSource);
|
|
||||||
// echo "______________________________";
|
|
||||||
// var_dump($recieverSource);
|
|
||||||
if ($memberSource === $recieverSource) {
|
if ($memberSource === $recieverSource) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ use Doctrine\Common\Collections\Collection;
|
|||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use App\Entity\Attribut\MemberRelationAttributInterface;
|
use App\Entity\Attribut\MemberRelationAttributInterface;
|
||||||
|
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
|
||||||
|
use App\Entity\EntityInterface;
|
||||||
|
|
||||||
final class SourceMemberInformation implements SourceMemberInformationInterface
|
final class SourceMemberInformation implements SourceMemberInformationInterface
|
||||||
{
|
{
|
||||||
@ -31,12 +33,47 @@ final class SourceMemberInformation implements SourceMemberInformationInterface
|
|||||||
{
|
{
|
||||||
foreach ($members as $member) {
|
foreach ($members as $member) {
|
||||||
if (!$this->members->contains($member)) {
|
if (!$this->members->contains($member)) {
|
||||||
$this->members->add($member);
|
$this->addMemberSource($member);
|
||||||
$this->itterateOverMembers($member->getMemberRelation()->getMembers());
|
$this->itterateOverMembers($this->getMemberMembers($member));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Implement tests!
|
||||||
|
*
|
||||||
|
* @param EntityInterface $member
|
||||||
|
*/
|
||||||
|
private function addMemberSource(EntityInterface $member): void
|
||||||
|
{
|
||||||
|
if ($member instanceof MemberRelationInterface) {
|
||||||
|
$this->members->add($member->getSource());
|
||||||
|
} else {
|
||||||
|
$this->members->add($member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Implement tests
|
||||||
|
*
|
||||||
|
* @param EntityInterface $member
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
private function getMemberMembers(EntityInterface $member): Collection
|
||||||
|
{
|
||||||
|
if ($member instanceof MemberRelationInterface) {
|
||||||
|
return $member->getMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $member->getMemberRelation()->getMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\SourceManagement\SourceMemberInformationInterface::getAllMembers()
|
||||||
|
*/
|
||||||
public function getAllMembers(): Collection
|
public function getAllMembers(): Collection
|
||||||
{
|
{
|
||||||
$this->members = new ArrayCollection();
|
$this->members = new ArrayCollection();
|
||||||
|
Loading…
Reference in New Issue
Block a user