mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 11:17:58 +00:00 
			
		
		
		
	Implemented standart rights for user sources
This commit is contained in:
		@@ -9,6 +9,7 @@ use Infinito\Domain\RequestManagement\Entity\RequestedEntityServiceInterface;
 | 
			
		||||
use Infinito\Exception\NotCorrectInstanceException;
 | 
			
		||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
 | 
			
		||||
use Infinito\Domain\LayerManagement\LayerInterfaceMap;
 | 
			
		||||
use FOS\UserBundle\Model\UserInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class is not ready and not tested!
 | 
			
		||||
@@ -123,6 +124,12 @@ final class EntityDomService implements EntityDomServiceInterface
 | 
			
		||||
                $domElement->setAttribute('id', $value->getId());
 | 
			
		||||
                $domElement->setAttribute('name', LayerType::getReadableValue($layer));
 | 
			
		||||
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if ($value instanceof UserInterface) {
 | 
			
		||||
                $domElement->setAttribute('value', $value->getId());
 | 
			
		||||
                $domElement->setAttribute('name', 'user');
 | 
			
		||||
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Infinito\Domain\UserManagement;
 | 
			
		||||
 | 
			
		||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
 | 
			
		||||
use Infinito\DBAL\Types\ActionType;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Containes the standart map.
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface UserSourceStandartRightMapInterface
 | 
			
		||||
{
 | 
			
		||||
    const LAYER_RIGHT_MAP = [
 | 
			
		||||
        LayerType::SOURCE => [
 | 
			
		||||
            ActionType::READ,
 | 
			
		||||
            ActionType::UPDATE,
 | 
			
		||||
        ],
 | 
			
		||||
    ];
 | 
			
		||||
}
 | 
			
		||||
@@ -24,7 +24,8 @@ class Right extends AbstractMeta implements RightInterface
 | 
			
		||||
    use ActionTypeAttribut,LawAttribut, GrantAttribut,ConditionAttribut,RecieverAttribut,LayerAttribut,PriorityAttribut;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\OneToOne(targetEntity="Infinito\Entity\Source\AbstractSource",cascade={"persist", "remove"})
 | 
			
		||||
     * @todo Implement Integrationtests
 | 
			
		||||
     * @ORM\ManyToOne(targetEntity="Infinito\Entity\Source\AbstractSource",cascade={"persist", "remove"})
 | 
			
		||||
     * @ORM\JoinColumn(name="source_id", referencedColumnName="id",onDelete="CASCADE")
 | 
			
		||||
     *
 | 
			
		||||
     * @var SourceInterface The requested source to which the law applies
 | 
			
		||||
@@ -57,8 +58,9 @@ class Right extends AbstractMeta implements RightInterface
 | 
			
		||||
    protected $layer;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @todo Test and implement it on an correct way!
 | 
			
		||||
     * @ORM\OneToOne(targetEntity="Infinito\Entity\Source\AbstractSource",cascade={"persist"})
 | 
			
		||||
     * @todo Implement Integrationtests
 | 
			
		||||
     * @todo implement it on an correct way!
 | 
			
		||||
     * @ORM\ManyToOne(targetEntity="Infinito\Entity\Source\AbstractSource",cascade={"persist"})
 | 
			
		||||
     * @ORM\JoinColumn(name="reciever_id", referencedColumnName="id",onDelete="CASCADE",nullable=true)
 | 
			
		||||
     *
 | 
			
		||||
     * @var SourceInterface|null if null then the right should apply to all sources
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@ use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use Infinito\Attribut\UserAttribut;
 | 
			
		||||
use Infinito\Entity\UserInterface;
 | 
			
		||||
use Infinito\Attribut\PersonIdentitySourceAttribut;
 | 
			
		||||
use Infinito\Entity\Meta\Right;
 | 
			
		||||
use Infinito\Domain\UserManagement\UserSourceStandartRightMapInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -31,11 +33,38 @@ class UserSource extends AbstractComplexSource implements UserSourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $personIdentitySource;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This function sets the standart rights for a user source.
 | 
			
		||||
     */
 | 
			
		||||
    private function setStandartRights(): void
 | 
			
		||||
    {
 | 
			
		||||
        foreach (UserSourceStandartRightMapInterface::LAYER_RIGHT_MAP as $layer => $actions) {
 | 
			
		||||
            foreach ($actions as $action) {
 | 
			
		||||
                $law = $this->law;
 | 
			
		||||
                $right = new Right();
 | 
			
		||||
                $right = new Right();
 | 
			
		||||
                $right->setSource($this);
 | 
			
		||||
                $right->setLaw($law);
 | 
			
		||||
                $right->setReciever($this);
 | 
			
		||||
                $right->setLayer($layer);
 | 
			
		||||
                $right->setActionType($action);
 | 
			
		||||
                $rights = $law->getRights();
 | 
			
		||||
                $rights->add($right);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct();
 | 
			
		||||
        $this->setStandartRights();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \Infinito\Entity\Source\Complex\UserSourceInterface::hasPersonIdentitySource()
 | 
			
		||||
     */
 | 
			
		||||
    public function hasPersonIdentitySource(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return isset($this->personIdentitySource);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user