Optimized RequestManagement and tests

This commit is contained in:
Kevin Frantz
2019-01-26 19:39:36 +01:00
parent 4731ef22a2
commit 4dd7ce8331
12 changed files with 115 additions and 36 deletions

View File

@@ -27,11 +27,6 @@ class RequestedRight implements RequestedRightInterface
*/
private $source;
/**
* @var RequestedEntityInterface
*/
private $requestedEntity;
/**
* @throws NotCorrectInstanceException
*/
@@ -40,11 +35,15 @@ class RequestedRight implements RequestedRightInterface
$entity = $this->requestedEntity->getEntity();
if ($entity instanceof SourceInterface) {
$this->source = $entity;
return;
}
if ($entity instanceof MetaInterface) {
$this->source = $entity->getSource();
return;
}
throw new NotCorrectInstanceException('The entity instance can\'t be processed');
throw new NotCorrectInstanceException('The entity instance '.get_class($entity).' can\'t be processed');
}
/**
@@ -92,7 +91,7 @@ class RequestedRight implements RequestedRightInterface
final public function setRequestedEntity(RequestedEntityInterface $requestedEntity): void
{
$this->requestedEntity = $requestedEntity;
if ($requestedEntity->getRequestedRight() !== $this) {
if (!$requestedEntity->hasRequestedRight()) {
$this->requestedEntity->setRequestedRight($this);
}
}