Optimized for SPA

This commit is contained in:
Kevin Frantz
2019-01-05 23:52:37 +01:00
parent 9e685260e9
commit bccd6efaff
393 changed files with 253 additions and 37 deletions

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Source\AbstractSource;
/**
* @author kevinfrantz
*/
abstract class AbstractComplexSource extends AbstractSource implements ComplexSourceInterface
{
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Entity\Source\Complex\Collection;
use App\Entity\Source\AbstractSource;
use App\Entity\Attribut\CollectionAttribut;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\SourceInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @author kevinfrantz
*/
abstract class AbstractCollectionSource extends AbstractSource implements CollectionSourceInterface
{
use CollectionAttribut;
/**
* @var Collection|SourceInterface[]
* @ORM\ManyToMany(targetEntity="App\Entity\Source\AbstractSource")
* @ORM\JoinTable(name="collection_source",
* joinColumns={@ORM\JoinColumn(name="collection_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="source_id", referencedColumnName="id")}
* )
*/
protected $collection;
public function __construct()
{
parent::__construct();
$this->collection = new ArrayCollection();
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Entity\Source\Complex\Collection;
use App\Entity\Source\SourceInterface;
use App\Entity\Attribut\CollectionAttributInterface;
interface CollectionSourceInterface extends SourceInterface, CollectionAttributInterface
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Entity\Source\Complex\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Entity
*/
class TreeCollectionSource extends AbstractCollectionSource implements TreeCollectionSourceInterface
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Entity\Source\Complex\Collection;
/**
* @author kevinfrantz
*/
interface TreeCollectionSourceInterface extends CollectionSourceInterface
{
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Source\SourceInterface;
/**
* Complex sources contain out of one or more primitive sources.
*
* @author kevinfrantz
*/
interface ComplexSourceInterface extends SourceInterface
{
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Attribut\FirstNameSourceAttribut;
use App\Entity\Attribut\SurnameSourceAttribut;
use App\Entity\Source\Primitive\Name\SurnameSource;
use App\Entity\Source\Primitive\Name\FirstNameSource;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Source\Primitive\Name\SurnameSourceInterface;
use App\Entity\Source\Primitive\Name\FirstNameSourceInterface;
/**
* @author kevinfrantz
* @ORM\Entity()
*/
class FullPersonNameSource extends AbstractComplexSource implements FullPersonNameSourceInterface
{
use FirstNameSourceAttribut,SurnameSourceAttribut;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Source\Primitive\Name\SurnameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="surname_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var SurnameSourceInterface
*/
protected $surnameSource;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Source\Primitive\Name\FirstNameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="firstname_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var FirstNameSourceInterface
*/
protected $firstNameSource;
public function __construct()
{
parent::__construct();
$this->surnameSource = new SurnameSource();
$this->firstNameSource = new FirstNameSource();
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Attribut\FirstNameSourceAttributInterface;
use App\Entity\Attribut\SurnameSourceAttributInterface;
/**
* @todo Maybe a middle name would be helpfull in the future ;)
*
* @author kevinfrantz
*/
interface FullPersonNameSourceInterface extends ComplexSourceInterface, FirstNameSourceAttributInterface, SurnameSourceAttributInterface
{
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Attribut\FullPersonNameSourceAttribut;
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Entity()
*/
class PersonIdentitySource extends AbstractComplexSource implements PersonIdentitySourceInterface
{
use FullPersonNameSourceAttribut;
/**
* @ORM\OneToOne(targetEntity="FullPersonNameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="fullname_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var FullPersonNameSourceInterface
*/
protected $fullPersonNameSource;
public function __construct()
{
parent::__construct();
$this->fullPersonNameSource = new FullPersonNameSource();
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Attribut\FullPersonNameSourceAttributInterface;
interface PersonIdentitySourceInterface extends ComplexSourceInterface, FullPersonNameSourceAttributInterface
{
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Entity\Source\Complex;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\UserAttribut;
use App\Entity\UserInterface;
use App\Entity\Attribut\PersonIdentitySourceAttribut;
/**
* @author kevinfrantz
* @ORM\Entity(repositoryClass="App\Repository\UserSourceRepository")
*/
class UserSource extends AbstractComplexSource implements UserSourceInterface
{
use UserAttribut,PersonIdentitySourceAttribut;
/**
* @ORM\OneToOne(targetEntity="App\Entity\User",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var UserInterface
*/
protected $user;
/**
* @ORM\OneToOne(targetEntity="PersonIdentitySource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="identity_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var PersonIdentitySourceInterface
*/
protected $personIdentitySource;
public function __construct()
{
parent::__construct();
}
public function hasPersonIdentitySource(): bool
{
return isset($this->personIdentitySource);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Entity\Source\Complex;
use App\Entity\Attribut\UserAttributInterface;
use App\Entity\Attribut\PersonIdentitySourceAttributInterface;
/**
* @author kevinfrantz
*/
interface UserSourceInterface extends ComplexSourceInterface, UserAttributInterface, PersonIdentitySourceAttributInterface
{
/**
* Checks if the user has an identity source.
*
* @return bool
*/
public function hasPersonIdentitySource(): bool;
}