Optimized folder draft

This commit is contained in:
Kevin Frantz
2018-10-03 15:38:45 +02:00
parent 74b45cb24d
commit e9e8fb91df
36 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Exclude;
use App\Entity\Interfaces\SourceInterface;
use App\Entity\Interfaces\NodeInterface;
/**
* @author kevinfrantz
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
* @ORM\Entity
* @ORM\Table(name="source")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"user" = "UserSource","name" = "NameSource"})
*/
abstract class AbstractSource extends AbstractEntity implements SourceInterface
{
use NodeAttribut;
/**
* @var NodeInterface
* @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
* @Exclude
*/
protected $node;
public function __construct()
{
parent::__construct();
$this->node = new Node();
$this->node->setSource($this);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NameAttribut;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Interfaces\NameSourceInterface;
/**
* @author kevinfrantz
* @ORM\Table(name="source_name")
* @ORM\Entity(repositoryClass="App\Repository\NameSourceRepository")
*/
class NameSource extends AbstractSource implements NameSourceInterface
{
use NameAttribut;
/**
* @ORM\Column(type="string",length=255)
* @Assert\NotBlank()
*
* @var string
*/
protected $name;
public function __construct()
{
parent::__construct();
$this->name = '';
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Entity\Interfaces;
use App\Entity\Attribut\Interfaces\NameAttributInterface;
/**
* @author kevinfrantz
*/
interface NameSourceInterface extends NameAttributInterface, SourceInterface
{
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Entity;
use App\Logic\Result\ResultInterface;
use App\Logic\Operation\OperationInterface;
use App\Logic\Operation\OperandInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Entity
* @ORM\Table(name="source_operation")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"and" = "AndOperation"})
*/
abstract class AbstractOperation extends AbstractSource implements OperationInterface
{
/**
* The result MUST NOT be saved via Doctrine!
*
* @var ResultInterface
*/
protected $result;
/**
* @var ArrayCollection|OperandInterface[]
*/
protected $operands;
public function getResult(): ResultInterface
{
return $this->result;
}
public function setOperators(ArrayCollection $operands): void
{
$this->operands = $operands;
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Entity;
use App\Logic\Operation\OperandInterface;
use App\Logic\Result\Result;
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Table(name="source_operation_user")
* @ORM\Entity()
*/
class AndOperation extends AbstractOperation
{
public function process(): void
{
if ($this->operands->isEmpty()) {
throw new \Exception('Operands must be defined!');
}
$this->result = new Result();
/**
* @var OperandInterface
*/
foreach ($this->operands->toArray() as $operand) {
if (!$operand->getResult()->getBool()) {
$this->result->setAll(false);
return;
}
}
$this->result->setAll(true);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Entity\Interfaces;
use App\Entity\Attribut\Interfaces\NodeAttributInterface;
use App\Entity\Attribut\Interfaces\RecieverAttributInterface;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @author kevinfrantz
*/
interface RecieverGroupInterface extends NodeAttributInterface, RecieverAttributInterface
{
public function getAllRecievers(): ArrayCollection;
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Attribut\UserAttribut;
use App\Entity\Attribut\NameSourceAttribut;
use App\Entity\Interfaces\UserSourceInterface;
use App\Entity\Interfaces\NameSourceInterface;
/**
* @author kevinfrantz
* @ORM\Table(name="source_user")
* @ORM\Entity(repositoryClass="App\Repository\UserSourceRepository")
*/
class UserSource extends AbstractSource implements UserSourceInterface
{
use UserAttribut,NameSourceAttribut;
/**
* @ORM\OneToOne(targetEntity="User",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*
* @var User
*/
protected $user;
/**
* @Assert\Type(type="App\Entity\NameSource")
* @Assert\Valid()
* @ORM\OneToOne(targetEntity="NameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="name_id", referencedColumnName="id")
*
* @var NameSourceInterface
*/
protected $nameSource;
public function __construct()
{
$this->nameSource = new NameSource();
parent::__construct();
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Entity\Interfaces;
use App\Entity\Attribut\Interfaces\UserAttributInterface;
use App\Entity\Attribut\Interfaces\NameSourceAttributInterface;
/**
* @author kevinfrantz
*/
interface UserSourceInterface extends SourceInterface, UserAttributInterface, NameSourceAttributInterface
{
}