mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Renamed TypeAttribut to CrudAttribut
This commit is contained in:
@@ -68,7 +68,7 @@ class SourceApiController extends AbstractAPIController
|
||||
// // $requestedRight = new Right();
|
||||
// // $requestedRight->setSource($requestedSource);
|
||||
// // $requestedRight->setLayer(LayerType::SOURCE);
|
||||
// // $requestedRight->setType(CRUDType::READ);
|
||||
// // $requestedRight->setCrud(CRUDType::READ);
|
||||
// // $sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
// // return $sourceResponseManager->getResponse();
|
||||
|
@@ -32,7 +32,7 @@ final class DefaultController extends AbstractController
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(CRUDType::READ);
|
||||
$requestedRight->setCrud(CRUDType::READ);
|
||||
$sourceResponseManager = new SourceRESTResponseManager($this->getUser(), $entityManager, $requestedRight, $this->getViewHandler());
|
||||
|
||||
return $sourceResponseManager->getResponse();
|
||||
|
@@ -65,7 +65,7 @@ class SourceFixtures extends Fixture
|
||||
$sourceRightManager = new SourceRightManager($this->impressumSource);
|
||||
$sourceRightManager->addRight($right);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setType(CRUDType::READ);
|
||||
$right->setCrud(CRUDType::READ);
|
||||
$right->setReciever($this->guestUserSource);
|
||||
|
||||
return $right;
|
||||
|
@@ -49,9 +49,9 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
|
||||
*
|
||||
* @return Collection|RightInterface[]
|
||||
*/
|
||||
private function getRightsByType(Collection $rights, string $type): Collection
|
||||
private function getRightsByCrud(Collection $rights, string $type): Collection
|
||||
{
|
||||
return $this->getFilteredRights($rights, $type, 'Type');
|
||||
return $this->getFilteredRights($rights, $type, 'Crud');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
|
||||
$right = $rights[0];
|
||||
$rightChecker = new RightChecker($right);
|
||||
|
||||
return $rightChecker->isGranted($client->getLayer(), $client->getType(), $client->getReciever());
|
||||
return $rightChecker->isGranted($client->getLayer(), $client->getCrud(), $client->getReciever());
|
||||
}
|
||||
|
||||
public function __construct(LawInterface $law)
|
||||
@@ -150,7 +150,7 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
|
||||
public function hasPermission(RightInterface $clientRight): bool
|
||||
{
|
||||
$rights = clone $this->law->getRights();
|
||||
$rights = $this->getRightsByType($rights, $clientRight->getType());
|
||||
$rights = $this->getRightsByCrud($rights, $clientRight->getCrud());
|
||||
$rights = $this->getRightsByLayer($rights, $clientRight->getLayer());
|
||||
$rights = $this->getRightsByReciever($rights, $clientRight->getReciever());
|
||||
$rights = $this->sortByPriority($rights);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\TypeAttribut;
|
||||
use App\Entity\Attribut\CrudAttribut;
|
||||
use App\Entity\Attribut\LayerAttribut;
|
||||
use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Exception\PreconditionFailedException;
|
||||
@@ -17,7 +17,7 @@ use App\Repository\Source\SourceRepositoryInterface;
|
||||
*/
|
||||
class RequestedRight implements RequestedRightInterface
|
||||
{
|
||||
use TypeAttribut, LayerAttribut, RecieverAttribut;
|
||||
use CrudAttribut, LayerAttribut, RecieverAttribut;
|
||||
|
||||
/**
|
||||
* @var SourceRepositoryInterface
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\CrudAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
@@ -10,7 +10,7 @@ use App\Entity\Source\SourceInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedRightInterface extends TypeAttributInterface, RecieverAttributInterface, LayerAttributInterface
|
||||
interface RequestedRightInterface extends CrudAttributInterface, RecieverAttributInterface, LayerAttributInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestedSourceInterface $requestedSource
|
||||
|
@@ -63,11 +63,11 @@ final class RequestedUserRightFacade implements RequestedUserRightFacadeInterfac
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Entity\Attribut\TypeAttributInterface::getType()
|
||||
* @see \App\Entity\Attribut\CrudAttributInterface::getCrud()
|
||||
*/
|
||||
public function getType(): string
|
||||
public function getCrud(): string
|
||||
{
|
||||
return $this->requestedRight->getType();
|
||||
return $this->requestedRight->getCrud();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,11 +93,11 @@ final class RequestedUserRightFacade implements RequestedUserRightFacadeInterfac
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Entity\Attribut\TypeAttributInterface::setType()
|
||||
* @see \App\Entity\Attribut\CrudAttributInterface::setCrud()
|
||||
*/
|
||||
public function setType(string $type): void
|
||||
public function setCrud(string $type): void
|
||||
{
|
||||
$this->requestedRight->setType($type);
|
||||
$this->requestedRight->setCrud($type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -45,7 +45,7 @@ final class RightChecker implements RightCheckerInterface
|
||||
|
||||
private function isTypeEqual(string $type): bool
|
||||
{
|
||||
return $this->right->getType() === $type;
|
||||
return $this->right->getCrud() === $type;
|
||||
}
|
||||
|
||||
private function checkPermission(): bool
|
||||
|
@@ -51,7 +51,7 @@ final class SecureCRUDFactoryService extends AbstractSecureCRUDService implement
|
||||
*/
|
||||
public function create(RightInterface $requestedRight): SecureCRUDServiceInterface
|
||||
{
|
||||
$namespace = $this->getCRUDNamespace($requestedRight->getLayer(), $requestedRight->getType());
|
||||
$namespace = $this->getCRUDNamespace($requestedRight->getLayer(), $requestedRight->getCrud());
|
||||
|
||||
return new $namespace($this->requestStack, $this->security, $this->entityManager);
|
||||
}
|
||||
|
@@ -119,9 +119,9 @@ final class TemplatePathInformation implements TemplatePathInformationInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getType()
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getCrud()
|
||||
*/
|
||||
public function getType(): string
|
||||
public function getCrud(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
@@ -26,5 +26,5 @@ interface TemplatePathInformationInterface extends ReloadTypeInterface
|
||||
*
|
||||
* @return string Type of the template
|
||||
*/
|
||||
public function getType(): string;
|
||||
public function getCrud(): string;
|
||||
}
|
||||
|
32
application/symfony/src/Entity/Attribut/CrudAttribut.php
Normal file
32
application/symfony/src/Entity/Attribut/CrudAttribut.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @todo Implement a trait for crud which substitute this one.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait CrudAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $crud;
|
||||
|
||||
/**
|
||||
* @param string $crud
|
||||
*/
|
||||
public function setCrud(string $crud): void
|
||||
{
|
||||
$this->crud = $crud;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCrud(): string
|
||||
{
|
||||
return $this->crud;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface CrudAttributInterface
|
||||
{
|
||||
public function setCrud(string $crud): void;
|
||||
|
||||
public function getCrud(): string;
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @todo Implement a trait for crud which substitute this one.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait TypeAttribut
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TypeAttributInterface
|
||||
{
|
||||
public function setType(string $type): void;
|
||||
|
||||
public function getType(): string;
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttribut;
|
||||
use App\Entity\Attribut\CrudAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||
use App\Entity\Attribut\LawAttribut;
|
||||
@@ -27,7 +27,7 @@ use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
*/
|
||||
class Right extends AbstractMeta implements RightInterface
|
||||
{
|
||||
use TypeAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut;
|
||||
use CrudAttribut,LawAttribut, RelationAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
||||
@@ -77,12 +77,12 @@ class Right extends AbstractMeta implements RightInterface
|
||||
protected $grant;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="CRUDType", nullable=false)
|
||||
* @ORM\Column(name="crud", type="CRUDType", nullable=false)
|
||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\Meta\Right\CRUDType")
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
protected $crud;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\Operation\AbstractOperation",cascade={"persist"})
|
||||
@@ -102,14 +102,14 @@ class Right extends AbstractMeta implements RightInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Entity\Attribut\TypeAttributInterface::setType()
|
||||
* @see \App\Entity\Attribut\CrudAttributInterface::setCrud()
|
||||
*/
|
||||
public function setType(string $type): void
|
||||
public function setCrud(string $crud): void
|
||||
{
|
||||
if (!array_key_exists($type, CRUDType::getChoices())) {
|
||||
if (!array_key_exists($crud, CRUDType::getChoices())) {
|
||||
throw new NoValidChoiceException();
|
||||
}
|
||||
$this->type = $type;
|
||||
$this->crud = $crud;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Entity\Meta;
|
||||
|
||||
use App\Entity\Attribut\TypeAttributInterface;
|
||||
use App\Entity\Attribut\CrudAttributInterface;
|
||||
use App\Entity\Attribut\LawAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\GrantAttributInterface;
|
||||
@@ -14,6 +14,6 @@ use App\Entity\Attribut\PriorityAttributInterface;
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface, PriorityAttributInterface
|
||||
interface RightInterface extends CrudAttributInterface, LawAttributInterface, GrantAttributInterface, RecieverAttributInterface, RelationAttributInterface, ConditionAttributInterface, LayerAttributInterface, MetaInterface, PriorityAttributInterface
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user