mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized folder draft
This commit is contained in:
39
application/src/Entity/Source/AbstractSource.php
Normal file
39
application/src/Entity/Source/AbstractSource.php
Normal 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);
|
||||
}
|
||||
}
|
32
application/src/Entity/Source/NameSource.php
Normal file
32
application/src/Entity/Source/NameSource.php
Normal 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 = '';
|
||||
}
|
||||
}
|
12
application/src/Entity/Source/NameSourceInterface.php
Normal file
12
application/src/Entity/Source/NameSourceInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Interfaces;
|
||||
|
||||
use App\Entity\Attribut\Interfaces\NameAttributInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface NameSourceInterface extends NameAttributInterface, SourceInterface
|
||||
{
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
33
application/src/Entity/Source/Operation/AndOperation.php
Normal file
33
application/src/Entity/Source/Operation/AndOperation.php
Normal 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);
|
||||
}
|
||||
}
|
15
application/src/Entity/Source/RecieverGroupInterface.php
Normal file
15
application/src/Entity/Source/RecieverGroupInterface.php
Normal 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;
|
||||
}
|
44
application/src/Entity/Source/UserSource.php
Normal file
44
application/src/Entity/Source/UserSource.php
Normal 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();
|
||||
}
|
||||
}
|
13
application/src/Entity/Source/UserSourceInterface.php
Normal file
13
application/src/Entity/Source/UserSourceInterface.php
Normal 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
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user