Optimized entity mapping

This commit is contained in:
Kevin Frantz 2018-11-20 22:04:29 +01:00
parent 0c852dbec4
commit 3b1330c40f
10 changed files with 34 additions and 10 deletions

View File

@ -12,7 +12,7 @@ use App\Entity\Attribut\RelationAttribut;
* @ORM\Table(name="meta_law")
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
*/
final class Law extends AbstractMeta implements LawInterface
class Law extends AbstractMeta implements LawInterface
{
use RightsAttribute, RelationAttribut;

View File

@ -22,7 +22,7 @@ use Doctrine\Common\Collections\Collection;
* @ORM\Table(name="meta_relation")
* @ORM\Entity()
*/
final class Relation extends AbstractMeta implements RelationInterface
class Relation extends AbstractMeta implements RelationInterface
{
use IdAttribut,
SourceAttribut,

View File

@ -20,7 +20,7 @@ use App\Entity\Attribut\RelationAttribut;
* @ORM\Table(name="meta_right")
* @ORM\Entity(repositoryClass="App\Repository\RightRepository")
*/
final class Right extends AbstractMeta implements RightInterface
class Right extends AbstractMeta implements RightInterface
{
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut;

View File

@ -7,6 +7,8 @@ use App\Entity\Attribut\SurnameSourceAttribut;
use App\Entity\Source\Data\Name\SurnameSource;
use App\Entity\Source\Data\Name\FirstNameSource;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Source\Data\Name\SurnameSourceInterface;
use App\Entity\Source\Data\Name\FirstNameSourceInterface;
/**
* @author kevinfrantz
@ -17,6 +19,22 @@ class FullPersonNameSource extends AbstractCombinationSource implements FullPers
{
use FirstNameSourceAttribut,SurnameSourceAttribut;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Source\Data\Name\SurnameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="surname_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var SurnameSourceInterface
*/
protected $surnameSource;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Source\Data\Name\FirstNameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="firstname_id", referencedColumnName="id",onDelete="CASCADE")
*
* @var FirstNameSourceInterface
*/
protected $firstnNameSource;
public function __construct()
{
parent::__construct();

View File

@ -16,7 +16,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"nickname" = "NicknameSource","firstname" = "FirstNameSource", "surname" = "SurnameSource"})
*/
abstract class AbstractNameSource extends AbstractDataSource implements NameSourceInterface
class AbstractNameSource extends AbstractDataSource implements NameSourceInterface
{
use NameAttribut;

View File

@ -2,6 +2,12 @@
namespace App\Entity\Source\Data\Name;
final class FirstNameSource extends AbstractNameSource implements FirstNameSourceInterface
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Entity()
*/
class FirstNameSource extends AbstractNameSource implements FirstNameSourceInterface
{
}

View File

@ -6,9 +6,8 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Table(name="source_data_name_nickname")
* @ORM\Entity()
*/
final class NicknameSource extends AbstractNameSource implements NicknameSourceInterface
class NicknameSource extends AbstractNameSource implements NicknameSourceInterface
{
}

View File

@ -6,9 +6,8 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Table(name="source_data_name_surname")
* @ORM\Entity()
*/
final class SurnameSource extends AbstractNameSource implements SurnameSourceInterface
class SurnameSource extends AbstractNameSource implements SurnameSourceInterface
{
}

View File

@ -14,7 +14,7 @@ use App\Exception\NotDefinedException;
*
* @todo move to the logic level!
*/
final class AndOperation extends AbstractOperation
class AndOperation extends AbstractOperation
{
public function process(): void
{

View File

@ -53,6 +53,8 @@ class UserRepositoryTest extends KernelTestCase
$this->assertGreaterThan(0, $this->loadedUser->getSource()->getId());
$this->assertGreaterThan(0, $this->loadedUser->getSource()->getPersonIdentitySource()->getId());
$this->assertGreaterThan(0, $this->loadedUser->getSource()->getPersonIdentitySource()->getFullPersonNameSource()->getId());
$this->assertGreaterThan(0, $this->loadedUser->getSource()->getPersonIdentitySource()->getFullPersonNameSource()->getFirstNameSource()->getId());
$this->assertGreaterThan(0, $this->loadedUser->getSource()->getPersonIdentitySource()->getFullPersonNameSource()->getSurnameSource()->getId());
$this->deleteUser();
$this->assertNull($this->userRepository->find($userId));
$this->loadedUser = null;