mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Implemented Permission draft
This commit is contained in:
parent
92886a14ce
commit
69f2beac72
@ -1,25 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\DBAL\Types;
|
namespace App\DBAL\Types;
|
||||||
|
|
||||||
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
final class RightType extends AbstractEnumType
|
final class RightType extends AbstractEnumType
|
||||||
{
|
{
|
||||||
public const ADMINISTRATION = 'administration';
|
public const ADMINISTRATION = 'administration';
|
||||||
|
|
||||||
public const READ = 'read';
|
public const READ = 'read';
|
||||||
|
|
||||||
public const WRITE = 'write';
|
public const WRITE = 'write';
|
||||||
|
|
||||||
protected static $choices = [
|
protected static $choices = [
|
||||||
self::ADMINISTRATION => 'administration',
|
self::ADMINISTRATION => 'administration',
|
||||||
self::READ => 'read',
|
self::READ => 'read',
|
||||||
self::WRITE=>'write',
|
self::WRITE => 'write',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\IdAttribut;
|
use App\Entity\Attribut\IdAttribut;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class AbstractEntity
|
class AbstractEntity
|
||||||
{
|
{
|
||||||
use IdAttribut;
|
use IdAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id()
|
* @ORM\Id()
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")(strategy="AUTO")
|
* @ORM\Column(type="integer")(strategy="AUTO")
|
||||||
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $id;
|
protected $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,15 +17,16 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
abstract class AbstractSource extends AbstractEntity implements SourceInterface
|
||||||
{
|
{
|
||||||
use NodeAttribut;
|
use NodeAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NodeInterface
|
* @var NodeInterface
|
||||||
* @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected $node;
|
protected $node;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$this->node = new Node();
|
$this->node = new Node();
|
||||||
$this->node->setSource($this);
|
$this->node->setSource($this);
|
||||||
}
|
}
|
||||||
|
24
application/src/Entity/Attribut/BlacklistAttribut.php
Normal file
24
application/src/Entity/Attribut/BlacklistAttribut.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
trait BlacklistAttribut
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $blacklist;
|
||||||
|
|
||||||
|
public function setBlacklist(?bool $value): void
|
||||||
|
{
|
||||||
|
$this->blacklist = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlacklist(): ?bool
|
||||||
|
{
|
||||||
|
return $this->blacklist;
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface BlacklistAttributInterface
|
interface BlacklistAttributInterface
|
||||||
{
|
{
|
||||||
@ -12,4 +11,3 @@ interface BlacklistAttributInterface
|
|||||||
|
|
||||||
public function getBlacklist(): ?bool;
|
public function getBlacklist(): ?bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\LawInterface;
|
use App\Entity\LawInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait LawAttribut {
|
trait LawAttribut
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @var LawInterface
|
* @var LawInterface
|
||||||
*/
|
*/
|
||||||
protected $law;
|
protected $law;
|
||||||
|
|
||||||
public function setLaw(LawInterface $law):void{
|
public function setLaw(LawInterface $law): void
|
||||||
|
{
|
||||||
$this->law = $law;
|
$this->law = $law;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLaw(): LawInterface{
|
public function getLaw(): LawInterface
|
||||||
|
{
|
||||||
return $this->law;
|
return $this->law;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\LawInterface;
|
use App\Entity\LawInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface LawAttributInterface
|
interface LawAttributInterface
|
||||||
{
|
{
|
||||||
|
public function setLaw(LawInterface $law): void;
|
||||||
public function setLaw(LawInterface $law):void;
|
|
||||||
|
|
||||||
public function getLaw(): LawInterface;
|
public function getLaw(): LawInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\RightInterface;
|
use App\Entity\RightInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface RightAttributInterface
|
interface RightAttributInterface
|
||||||
{
|
{
|
||||||
public function setRight(RightInterface $right):void;
|
public function setRight(RightInterface $right): void;
|
||||||
|
|
||||||
public function getRight():RightInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getRight(): RightInterface;
|
||||||
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface RightsAttributInterface
|
interface RightsAttributInterface
|
||||||
{
|
{
|
||||||
public function setRights(ArrayCollection $rights):void;
|
public function setRights(ArrayCollection $rights): void;
|
||||||
|
|
||||||
public function getRights():ArrayCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getRights(): ArrayCollection;
|
||||||
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait RightsAttribute {
|
trait RightsAttribute
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @var ArrayCollection
|
* @var ArrayCollection
|
||||||
*/
|
*/
|
||||||
protected $rights;
|
protected $rights;
|
||||||
|
|
||||||
public function setRights(ArrayCollection $rights):void{
|
public function setRights(ArrayCollection $rights): void
|
||||||
|
{
|
||||||
$this->rights = $rights;
|
$this->rights = $rights;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRights():ArrayCollection{
|
public function getRights(): ArrayCollection
|
||||||
|
{
|
||||||
return $this->rights;
|
return $this->rights;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait TypeAttribut {
|
trait TypeAttribut
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
public function setType(string $type):void{
|
public function setType(string $type): void
|
||||||
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType():string{
|
public function getType(): string
|
||||||
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface TypeAttributInterface
|
interface TypeAttributInterface
|
||||||
{
|
{
|
||||||
public function setType(string $type):void;
|
public function setType(string $type): void;
|
||||||
|
|
||||||
public function getType():string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getType(): string;
|
||||||
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait UserAttribut {
|
trait UserAttribut
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @var User
|
* @var User
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
public function setUser(User $user):void{
|
public function setUser(User $user): void
|
||||||
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser():User{
|
public function getUser(): User
|
||||||
|
{
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Attribut;
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface UserAttributInterface
|
interface UserAttributInterface
|
||||||
{
|
{
|
||||||
public function setUser(User $user):void;
|
public function setUser(User $user): void;
|
||||||
|
|
||||||
public function getUser():User;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getUser(): User;
|
||||||
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Entity\Attribut;
|
namespace Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\UserSourceInterface;
|
use App\Entity\UserSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
trait UserSource {
|
trait UserSource
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var UserSourceInterface
|
* @var UserSourceInterface
|
||||||
* @ORM\OneToOne(targetEntity="UserSource",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="UserSource",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="source_user_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="source_user_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected $userSource;
|
protected $userSource;
|
||||||
|
|
||||||
public function setUserSource(UserSourceInterface $userSource):void{
|
public function setUserSource(UserSourceInterface $userSource): void
|
||||||
|
{
|
||||||
$this->user = $userSource;
|
$this->user = $userSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserSource():UserSourceInterface{
|
public function getUserSource(): UserSourceInterface
|
||||||
|
{
|
||||||
return $this->userSource;
|
return $this->userSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Entity\Attribut;
|
namespace Entity\Attribut;
|
||||||
|
|
||||||
use App\Entity\UserSourceInterface;
|
use App\Entity\UserSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface UserSourceAttributInterface
|
interface UserSourceAttributInterface
|
||||||
{
|
{
|
||||||
public function setUserSource(UserSourceInterface $user):void;
|
public function setUserSource(UserSourceInterface $user): void;
|
||||||
|
|
||||||
public function getUserSource():UserSourceInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getUserSource(): UserSourceInterface;
|
||||||
|
}
|
||||||
|
24
application/src/Entity/Attribut/WhitelistAttribut.php
Normal file
24
application/src/Entity/Attribut/WhitelistAttribut.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
trait WhitelistAttribut
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $whitelist;
|
||||||
|
|
||||||
|
public function setWhitelist(?bool $value): void
|
||||||
|
{
|
||||||
|
$this->whitelist = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWhitelist(): ?bool
|
||||||
|
{
|
||||||
|
return $this->whitelist;
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Entity\Attribut;
|
namespace Entity\Attribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface WhitelistAttributInterface
|
interface WhitelistAttributInterface
|
||||||
{
|
{
|
||||||
public function setWhitelist(?bool $value): void;
|
public function setWhitelist(?bool $value): void;
|
||||||
|
|
||||||
public function getWhitelist(): ?bool;
|
public function getWhitelist(): ?bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@ -8,7 +9,6 @@ use App\DBAL\Types\RightType;
|
|||||||
use App\Entity\Attribut\NodeAttribut;
|
use App\Entity\Attribut\NodeAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="law")
|
* @ORM\Table(name="law")
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\LawRepository")
|
||||||
@ -18,8 +18,8 @@ class Law extends AbstractEntity implements LawInterface
|
|||||||
use RightsAttribute, NodeAttribut;
|
use RightsAttribute, NodeAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"})
|
* @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"})
|
||||||
|
*
|
||||||
* @var ArrayCollection
|
* @var ArrayCollection
|
||||||
*/
|
*/
|
||||||
protected $rights;
|
protected $rights;
|
||||||
@ -27,10 +27,11 @@ class Law extends AbstractEntity implements LawInterface
|
|||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="Node",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
* @var NodeInterface
|
* @var NodeInterface
|
||||||
*/
|
*/
|
||||||
protected $node;
|
protected $node;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->initAllRights();
|
$this->initAllRights();
|
||||||
@ -39,13 +40,11 @@ class Law extends AbstractEntity implements LawInterface
|
|||||||
private function initAllRights(): void
|
private function initAllRights(): void
|
||||||
{
|
{
|
||||||
$this->rights = new ArrayCollection();
|
$this->rights = new ArrayCollection();
|
||||||
foreach (RightType::getChoices() as $key=>$value){
|
foreach (RightType::getChoices() as $key => $value) {
|
||||||
$right = new Right();
|
$right = new Right();
|
||||||
$right->setType($value);
|
$right->setType($value);
|
||||||
$right->setLaw($this);
|
$right->setLaw($this);
|
||||||
$this->rights->set($key, $right);
|
$this->rights->set($key, $right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\RightsAttributInterface;
|
use App\Entity\Attribut\RightsAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface LawInterface extends RightsAttributInterface
|
interface LawInterface extends RightsAttributInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,22 +21,25 @@ class Node extends AbstractEntity implements NodeInterface
|
|||||||
ParentAttribut,
|
ParentAttribut,
|
||||||
LawAttribut,
|
LawAttribut,
|
||||||
ChildsAttribut;
|
ChildsAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="AbstractSource",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="AbstractSource",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="source_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="source_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
* @var SourceInterface
|
* @var SourceInterface
|
||||||
*/
|
*/
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="Law",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
* @var LawInterface
|
* @var LawInterface
|
||||||
*/
|
*/
|
||||||
protected $law;
|
protected $law;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct()
|
||||||
|
{
|
||||||
$this->law = new Law();
|
$this->law = new Law();
|
||||||
$this->law->setNode($this);
|
$this->law->setNode($this);
|
||||||
}
|
}
|
||||||
|
31
application/src/Entity/Permission.php
Normal file
31
application/src/Entity/Permission.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use App\Entity\Attribut\BlacklistAttribut;
|
||||||
|
use App\Entity\Attribut\WhitelistAttribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
* @ORM\Table(name="permission")
|
||||||
|
* @ORM\Entity(repositoryClass="App\Repository\PermissionRepository")
|
||||||
|
*/
|
||||||
|
class Permission extends AbstractEntity implements PermissionInterface
|
||||||
|
{
|
||||||
|
use BlacklistAttribut,WhitelistAttribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $blacklist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $whitelist;
|
||||||
|
}
|
@ -1,16 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Entity;
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\BlacklistAttributInterface;
|
use App\Entity\Attribut\BlacklistAttributInterface;
|
||||||
use Entity\Attribut\WhitelistAttributInterface;
|
use Entity\Attribut\WhitelistAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface
|
interface PermissionInterface extends BlacklistAttributInterface, WhitelistAttributInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
@ -6,11 +7,9 @@ use App\Entity\Attribut\TypeAttribut;
|
|||||||
use App\DBAL\Types\RightType;
|
use App\DBAL\Types\RightType;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
|
||||||
use App\Entity\Attribut\LawAttributInterface;
|
|
||||||
use App\Entity\Attribut\LawAttribut;
|
use App\Entity\Attribut\LawAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="`right`")
|
* @ORM\Table(name="`right`")
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\RightRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\RightRepository")
|
||||||
@ -18,26 +17,35 @@ use App\Entity\Attribut\LawAttribut;
|
|||||||
class Right extends AbstractEntity implements RightInterface
|
class Right extends AbstractEntity implements RightInterface
|
||||||
{
|
{
|
||||||
use TypeAttribut,LawAttribut;
|
use TypeAttribut,LawAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Law",cascade={"persist", "remove"})
|
* @ORM\ManyToOne(targetEntity="Law",cascade={"persist", "remove"})
|
||||||
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="law_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
* @var LawInterface
|
* @var LawInterface
|
||||||
*/
|
*/
|
||||||
protected $law;
|
protected $law;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="type", type="RightType", nullable=false)
|
* @ORM\Column(name="type", type="RightType", nullable=false)
|
||||||
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RightType")
|
* @DoctrineAssert\Enum(entity="App\DBAL\Types\RightType")
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Right", mappedBy="id", cascade={"persist", "remove"})
|
||||||
|
*
|
||||||
|
* @var ArrayCollection
|
||||||
|
*/
|
||||||
|
protected $permissions;
|
||||||
|
|
||||||
public function isGranted(NodeInterface $node): bool
|
public function isGranted(NodeInterface $node): bool
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function setPermissions(ArrayCollection $permissions): void
|
public function setPermissions(ArrayCollection $permissions): void
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
@ -6,14 +7,11 @@ use App\Entity\Attribut\TypeAttributInterface;
|
|||||||
use App\Entity\Attribut\LawAttributInterface;
|
use App\Entity\Attribut\LawAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface RightInterface extends TypeAttributInterface, LawAttributInterface
|
interface RightInterface extends TypeAttributInterface, LawAttributInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function isGranted(NodeInterface $node): bool;
|
public function isGranted(NodeInterface $node): bool;
|
||||||
|
|
||||||
public function setPermissions(ArrayCollection $permissions):void;
|
public function setPermissions(ArrayCollection $permissions): void;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class User extends BaseUser implements SourceAttributInterface
|
|||||||
* @ORM\JoinColumn(name="source_user_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="source_user_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="is_active", type="boolean")
|
* @ORM\Column(name="is_active", type="boolean")
|
||||||
*/
|
*/
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use App\Entity\Attribut\UserAttribut;
|
use App\Entity\Attribut\UserAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
* @ORM\Table(name="source_user")
|
* @ORM\Table(name="source_user")
|
||||||
* @ORM\Entity(repositoryClass="App\Repository\UserSourceRepository")
|
* @ORM\Entity(repositoryClass="App\Repository\UserSourceRepository")
|
||||||
@ -13,12 +13,12 @@ use App\Entity\Attribut\UserAttribut;
|
|||||||
class UserSource extends AbstractSource implements UserSourceInterface
|
class UserSource extends AbstractSource implements UserSourceInterface
|
||||||
{
|
{
|
||||||
use UserAttribut;
|
use UserAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="User")
|
* @ORM\OneToOne(targetEntity="User")
|
||||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
* @var User
|
* @var User
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Entity\Attribut\UserAttributInterface;
|
use App\Entity\Attribut\UserAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
interface UserSourceInterface extends SourceInterface, UserAttributInterface
|
interface UserSourceInterface extends SourceInterface, UserAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user