Optimized reciever

This commit is contained in:
Kevin Frantz 2018-10-31 21:07:57 +01:00
parent 48697c8b12
commit 0a18123384
3 changed files with 18 additions and 7 deletions

View File

@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\RelationAttribut;
use App\Entity\Attribut\RelationAttributInterface;
use App\Entity\Attribut\MembersAttribut;
use App\Entity\Source\SourceInterface;
/**
* @author kevinfrantz
@ -27,9 +28,19 @@ class Reciever extends AbstractMeta implements RecieverInterface
*/
protected $relation;
public function getAllRecievers(): ArrayCollection
/**
* @ORM\ManyToMany(targetEntity="App\Entity\AbstractSource")
* @ORM\JoinTable(name="meta_reciever_members",
* joinColumns={@ORM\JoinColumn(name="reciever_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id")}
* )
*
* @var ArrayCollection | SourceInterface[]
*/
protected $members;
public function __construct()
{
foreach ($this->members->getValues() as $source) {
}
$this->members = new ArrayCollection();
}
}

View File

@ -2,14 +2,14 @@
namespace App\Entity\Meta;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Attribut\RelationAttributInterface;
use App\Entity\Attribut\MembersAttributInterface;
/**
* It's neccessary to have an own reciever class, because if you would use a GroupSource it would lead to an infinite loop.
*
* @author kevinfrantz
*/
interface RecieverInterface extends RelationAttributInterface, MetaInterface, MembersAttributInterface
{
public function getAllRecievers(): ArrayCollection;
}

View File

@ -3,9 +3,9 @@
namespace App\Tests\Unit\Entity\Meta;
use PHPUnit\Framework\TestCase;
use Doctrine\Common\Collections\Collection;
use App\Entity\Meta\Reciever;
use App\Entity\Meta\RecieverInterface;
use Doctrine\Common\Collections\Collection;
class RecieverTest extends TestCase
{
@ -21,6 +21,6 @@ class RecieverTest extends TestCase
public function testConstructor(): void
{
$this->assertEquals(Collection::class, $this->reciever->getAllRecievers());
$this->assertInstanceOf(Collection::class, $this->reciever->getMembers());
}
}