mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Added source collection draft
This commit is contained in:
parent
e066e8b362
commit
4bd1078491
@ -14,6 +14,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @todo rename and refactor this class
|
||||
* @ORM\Table(name="node")
|
||||
* @ORM\Entity()
|
||||
*/
|
||||
@ -39,7 +40,8 @@ class Node extends AbstractEntity implements NodeInterface
|
||||
|
||||
/**
|
||||
* Many Nodes have many childs.
|
||||
*
|
||||
* @todo Replace this by self referencing
|
||||
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html
|
||||
* @ORM\ManyToMany(targetEntity="Node")
|
||||
* @ORM\JoinTable(name="nodes_childs",
|
||||
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
|
||||
|
@ -17,7 +17,7 @@ use App\Entity\Node;
|
||||
* @ORM\Table(name="source")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="discr", type="string")
|
||||
* @ORM\DiscriminatorMap({"user" = "UserSource","name" = "NameSource"})
|
||||
* @ORM\DiscriminatorMap({"user" = "UserSource","name" = "NameSource","collection" = "SourceCollection"})
|
||||
*/
|
||||
abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
||||
{
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace App\Entity\Source\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
trait SourceMembersAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $members;
|
||||
|
||||
public function getMembers():Collection{
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
public function setMembers(Collection $members):void{
|
||||
$this->members = $members;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Entity\Source\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* Allows to group other sources in a source
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface SourceMembersAttributInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Sets the collection source members
|
||||
*
|
||||
* @param Collection $members
|
||||
*/
|
||||
public function setMembers(Collection $members): void;
|
||||
|
||||
/**
|
||||
* Returns the collection source members
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMembers(): Collection;
|
||||
}
|
||||
|
176
application/src/Entity/Source/SourceCollection.php
Normal file
176
application/src/Entity/Source/SourceCollection.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
namespace App\Entity\Source;
|
||||
|
||||
use App\Entity\Source\Attribut\SourceMembersAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
* @ORM\Table(name="source_collection")
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class SourceCollection extends AbstractSource implements SourceCollectionInterface
|
||||
{
|
||||
use SourceMembersAttribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Collection
|
||||
* @ORM\ManyToMany(targetEntity="AbstractSource")
|
||||
*/
|
||||
protected $members;
|
||||
|
||||
public function next()
|
||||
{
|
||||
return $this->members->next();
|
||||
}
|
||||
|
||||
public function forAll(Closure $p)
|
||||
{
|
||||
return $this->members->forAll($p);
|
||||
}
|
||||
|
||||
public function remove($key)
|
||||
{
|
||||
return $this->members->remove($key);
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return $this->members->current();
|
||||
}
|
||||
|
||||
public function partition(Closure $p)
|
||||
{
|
||||
return $this->members->partition($p);
|
||||
}
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $this->offsetExists($offset);
|
||||
}
|
||||
|
||||
public function slice($offset, $length = null)
|
||||
{
|
||||
return $this->slice($offset, $length);
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
return $this->members->get($key);
|
||||
}
|
||||
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
return $this->members->offsetUnset($offset);
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return $this->members->toArray();
|
||||
}
|
||||
|
||||
public function map(Closure $func)
|
||||
{
|
||||
return $this->members->map($func);
|
||||
}
|
||||
|
||||
public function indexOf($element)
|
||||
{
|
||||
return $this->members->indexOf($element);
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return $this->members->key();
|
||||
}
|
||||
|
||||
public function add($element)
|
||||
{
|
||||
return $this->add($element);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->members->offsetGet($offset);
|
||||
}
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
return $this->members->set($key, $value);
|
||||
}
|
||||
|
||||
public function getValues()
|
||||
{
|
||||
return $this->members->getValues();
|
||||
}
|
||||
|
||||
public function last()
|
||||
{
|
||||
return $this->members->last();
|
||||
}
|
||||
|
||||
public function containsKey($key)
|
||||
{
|
||||
return $this->members->containsKey($key);
|
||||
}
|
||||
|
||||
public function clear()
|
||||
{
|
||||
return $this->members->clear();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->members->isEmpty();
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return $this->members->count();
|
||||
}
|
||||
|
||||
public function getKeys()
|
||||
{
|
||||
return $this->members->getKeys();
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
return $this->members->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
public function filter(Closure $p)
|
||||
{
|
||||
return $this->members->filter($p);
|
||||
}
|
||||
|
||||
public function contains($element)
|
||||
{
|
||||
return $this->members->contains($element);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return $this->members->getIterator();
|
||||
}
|
||||
|
||||
public function exists(Closure $p)
|
||||
{
|
||||
return $this->members->exists($p);
|
||||
}
|
||||
|
||||
public function removeElement($element)
|
||||
{
|
||||
return $this->members->removeElement($element);
|
||||
}
|
||||
|
||||
public function first()
|
||||
{
|
||||
return $this->members->first();
|
||||
}
|
||||
}
|
||||
|
107
application/src/Entity/Source/SourceCollectionInterface.php
Normal file
107
application/src/Entity/Source/SourceCollectionInterface.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
namespace App\Entity\Source;
|
||||
|
||||
use App\Entity\Source\Attribut\SourceMembersAttributInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* Allows to handle SourceCollections like normal collections.
|
||||
* This interface also specifies the parameters of the collection interface via PHPDoc
|
||||
*
|
||||
* @author kevinfrantz
|
||||
* @todo Map the not jet mapped functions!
|
||||
*
|
||||
*/
|
||||
interface SourceCollectionInterface extends SourceMembersAttributInterface, Collection
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SourceInterface $element
|
||||
* @return bool
|
||||
*/
|
||||
public function add($element);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SourceInterface $element
|
||||
* @return bool
|
||||
*/
|
||||
public function contains($element);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SourceInterface $element
|
||||
* @return bool
|
||||
*/
|
||||
public function removeElement($element);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|int $key
|
||||
* @return SourceInterface|null
|
||||
*/
|
||||
public function get($key);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array|SourceInterface[]
|
||||
*/
|
||||
public function getValues();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|int $key
|
||||
* @param SourceInterface $value
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, $value);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array|SourceInterface[]
|
||||
*/
|
||||
public function toArray();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function last();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function current();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return SourceInterface
|
||||
*/
|
||||
public function next();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SourceInterface $element
|
||||
*
|
||||
* @return int|string|bool
|
||||
*/
|
||||
public function indexOf($element);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int|null $length
|
||||
*
|
||||
* @return array|SourceInterface[]
|
||||
*/
|
||||
public function slice($offset, $length = null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user