mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 11:17:58 +00:00 
			
		
		
		
	Deleted unnecessary classes
This commit is contained in:
		@@ -1,79 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Structur\Facade\Security\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Entity\User;
 | 
			
		||||
use App\DBAL\Types\RightType;
 | 
			
		||||
use App\DBAL\Types\LayerType;
 | 
			
		||||
use App\Entity\Meta\RelationInterface;
 | 
			
		||||
use App\Entity\Meta\Relation;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractSourceFacade implements SourceFacadeInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Propably it woul be better to solve this over the constructor.
 | 
			
		||||
     *
 | 
			
		||||
     * @var User
 | 
			
		||||
     */
 | 
			
		||||
    protected static $facadeUser;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $source;
 | 
			
		||||
 | 
			
		||||
    public static function setFacadeUser(User $facadeUser): void
 | 
			
		||||
    {
 | 
			
		||||
        self::$facadeUser = $facadeUser;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __construct(SourceInterface $source)
 | 
			
		||||
    {
 | 
			
		||||
        $this->source = $source;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setId(int $id): void
 | 
			
		||||
    {
 | 
			
		||||
        throw \Exception("The id can't be changed!");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setRelation(RelationInterface $relation): void
 | 
			
		||||
    {
 | 
			
		||||
        throw \Exception("The node can't be changed!");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getId(): int
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->isGranted(RightType::READ)) {
 | 
			
		||||
            return $source->getId();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getRelation(): Relation
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->isGranted(RightType::READ, LayerType::NODE)) {
 | 
			
		||||
            return $source->getNode();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function isGranted(string $right, string $layer): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->getNode()
 | 
			
		||||
            ->getLaw()
 | 
			
		||||
            ->isGranted(self::$user->getSource()
 | 
			
		||||
            ->getNode(), self::$layer, $right);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function lazyLoadSourceFacade(SourceInterface $source)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __toString(): string
 | 
			
		||||
    {
 | 
			
		||||
        return $this->source->__toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Structur\Facade\Security\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface SourceFacadeInterface extends SourceInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -1,118 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Structur\Facade\Security\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Meta\LawInterface;
 | 
			
		||||
use App\Entity\Source\NameSourceInterface;
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Entity\UserInterface;
 | 
			
		||||
use App\Entity\Source\UserSourceInterface;
 | 
			
		||||
use App\DBAL\Types\RightType;
 | 
			
		||||
use App\DBAL\Types\LayerType;
 | 
			
		||||
use Doctrine\Common\Collections\Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @todo check if this layer makes sense
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var UserSourceInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $source;
 | 
			
		||||
 | 
			
		||||
    public function setNameSource(NameSourceInterface $nameSource): void
 | 
			
		||||
    {
 | 
			
		||||
        throw new \Exception('The name source cant be changed!');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getNameSource(): NameSourceInterface
 | 
			
		||||
    {
 | 
			
		||||
        if ($this->isNameSourceGranted(RightType::READ, LayerType::SOURCE)) {
 | 
			
		||||
            // FILL! :)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function isNameSourceGranted(string $right, string $layer): bool
 | 
			
		||||
    {
 | 
			
		||||
        $nameSource = $this->source->getNameSource();
 | 
			
		||||
        $law = $nameSource->getNode()->getLaw();
 | 
			
		||||
        $userSourceNode = $this->source->getNode();
 | 
			
		||||
 | 
			
		||||
        return $this->isGranted($right, $layer) && $law->isGranted($userSourceNode, $layer, $right);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getUser(): UserInterface
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setUser(UserInterface $user): void
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getVersion(): int
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setVersion(int $version): void
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setSource(SourceInterface $source): void
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getGroupSources(): Collection
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getSource(): SourceInterface
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setGroupSources(Collection $groups): void
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function setLaw(LawInterface $law): void
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLaw(): LawInterface
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
         *
 | 
			
		||||
         * @todo Implement
 | 
			
		||||
         */
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user