mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Added default grant value for law
This commit is contained in:
parent
1ee710e608
commit
3efa57f29a
@ -134,7 +134,7 @@ final class LawPermissionCheckerService implements LawPermissionCheckerServiceIn
|
|||||||
private function isGranted(Collection $rights, RightInterface $client): bool
|
private function isGranted(Collection $rights, RightInterface $client): bool
|
||||||
{
|
{
|
||||||
if (0 === $rights->count()) {
|
if (0 === $rights->count()) {
|
||||||
return false;
|
return $this->law->getGrant();
|
||||||
}
|
}
|
||||||
$right = $rights[0];
|
$right = $rights[0];
|
||||||
$rightChecker = new RightChecker($right);
|
$rightChecker = new RightChecker($right);
|
||||||
|
@ -7,6 +7,7 @@ use App\Entity\Attribut\RightsAttribute;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use App\Entity\Attribut\RelationAttribut;
|
use App\Entity\Attribut\RelationAttribut;
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
|
use App\Entity\Attribut\GrantAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -15,7 +16,14 @@ use App\Entity\Source\SourceInterface;
|
|||||||
*/
|
*/
|
||||||
class Law extends AbstractMeta implements LawInterface
|
class Law extends AbstractMeta implements LawInterface
|
||||||
{
|
{
|
||||||
use RightsAttribute, RelationAttribut;
|
use RightsAttribute, RelationAttribut, GrantAttribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean",name="`grant`")
|
||||||
|
*
|
||||||
|
* @var bool the standart grant value
|
||||||
|
*/
|
||||||
|
protected $grant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="App\Entity\Source\AbstractSource",cascade={"persist", "remove"})
|
||||||
@ -36,5 +44,6 @@ class Law extends AbstractMeta implements LawInterface
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->rights = new ArrayCollection();
|
$this->rights = new ArrayCollection();
|
||||||
|
$this->grant = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
namespace App\Entity\Meta;
|
namespace App\Entity\Meta;
|
||||||
|
|
||||||
use App\Entity\Attribut\RightsAttributInterface;
|
use App\Entity\Attribut\RightsAttributInterface;
|
||||||
|
use App\Entity\Attribut\GrantAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface LawInterface extends RightsAttributInterface, MetaInterface
|
interface LawInterface extends RightsAttributInterface, MetaInterface, GrantAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -202,4 +202,11 @@ class LawPermissionCheckerTest extends TestCase
|
|||||||
]));
|
]));
|
||||||
$this->assertTrue($this->checkClientPermission());
|
$this->assertTrue($this->checkClientPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGrant(): void
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->checkClientPermission());
|
||||||
|
$this->law->setGrant(true);
|
||||||
|
$this->assertTrue($this->checkClientPermission());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class LawTest extends TestCase
|
|||||||
|
|
||||||
public function testConstruct(): void
|
public function testConstruct(): void
|
||||||
{
|
{
|
||||||
|
$this->assertFalse($this->law->getGrant());
|
||||||
$this->assertInstanceOf(Collection::class, $this->law->getRights());
|
$this->assertInstanceOf(Collection::class, $this->law->getRights());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user