mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Implemented not functional draft for SecureSourceReadService
This commit is contained in:
parent
ff95e23859
commit
1a3c9874a4
@ -13,6 +13,7 @@ use App\Domain\SecureCRUDManagement\CRUD\AbstractSecureCRUDService;
|
||||
use App\Entity\EntityInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use App\Repository\Source\SourceRepository;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -22,7 +23,7 @@ final class SecureSourceReadService extends AbstractSecureCRUDService //implemen
|
||||
/**
|
||||
* @todo It would be better to specify the type
|
||||
*
|
||||
* @var ObjectRepository
|
||||
* @var SourceRepository
|
||||
*/
|
||||
private $sourceRepository;
|
||||
|
||||
@ -39,18 +40,6 @@ final class SecureSourceReadService extends AbstractSecureCRUDService //implemen
|
||||
return $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SourceInterface
|
||||
*/
|
||||
private function loadSource(): SourceInterface
|
||||
{
|
||||
try {
|
||||
return $this->sourceRepository->find($this->requestedRight->getSource()->getId());
|
||||
} catch (\Error $error) {
|
||||
return $this->sourceRepository->findOneBySlug($this->requestedRight->getSource()->getSlug());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -63,13 +52,14 @@ final class SecureSourceReadService extends AbstractSecureCRUDService //implemen
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo This will not work! Change interface to requested right!
|
||||
* @param RightInterface $requestedRight
|
||||
*
|
||||
* @return EntityInterface
|
||||
*/
|
||||
public function read(RightInterface $requestedRight): EntityInterface
|
||||
{
|
||||
$source = $this->loadSource();
|
||||
$source = $requestedRight->getSource();
|
||||
$requestedRight = $this->getClonedRightWithModifiedSource($source, $requestedRight);
|
||||
$secureSourceChecker = new SecureSourceChecker($source);
|
||||
if ($secureSourceChecker->hasPermission($requestedRight)) {
|
||||
|
Loading…
Reference in New Issue
Block a user