mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Solved bug in SourceMemberInformation
This commit is contained in:
		| @@ -83,12 +83,8 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn | ||||
|     private function memberExist(RightInterface $right, SourceInterface $recieverSource): bool | ||||
|     { | ||||
|         $rightMemberInformation = new SourceMemberInformation($right->getReciever()); | ||||
| //         $rightMemberSources = $rightMemberInformation->getAllMembers(); | ||||
|         $rightMemberSources = new ArrayCollection(); | ||||
|         $rightMemberSources = $rightMemberInformation->getAllMembers(); | ||||
|         foreach ($rightMemberSources as $memberSource) { | ||||
| //             var_dump($memberSource); | ||||
| //             echo "______________________________"; | ||||
| //             var_dump($recieverSource); | ||||
|             if ($memberSource === $recieverSource) { | ||||
|                 return true; | ||||
|             } | ||||
|   | ||||
| @@ -6,6 +6,8 @@ use Doctrine\Common\Collections\Collection; | ||||
| use App\Entity\Source\SourceInterface; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use App\Entity\Attribut\MemberRelationAttributInterface; | ||||
| use App\Entity\Meta\Relation\Member\MemberRelationInterface; | ||||
| use App\Entity\EntityInterface; | ||||
|  | ||||
| final class SourceMemberInformation implements SourceMemberInformationInterface | ||||
| { | ||||
| @@ -31,12 +33,47 @@ final class SourceMemberInformation implements SourceMemberInformationInterface | ||||
|     { | ||||
|         foreach ($members as $member) { | ||||
|             if (!$this->members->contains($member)) { | ||||
|                 $this->members->add($member); | ||||
|                 $this->itterateOverMembers($member->getMemberRelation()->getMembers()); | ||||
|                 $this->addMemberSource($member); | ||||
|                 $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 | ||||
|     { | ||||
|         $this->members = new ArrayCollection(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user