In between commit Exception refactoring

This commit is contained in:
Kevin Frantz
2019-04-14 23:37:30 +02:00
parent 679bfd2079
commit 9f179ead73
64 changed files with 256 additions and 241 deletions

View File

@@ -2,14 +2,14 @@
namespace Infinito\Domain\DataAccessManagement;
use Doctrine\Common\Collections\Collection;
use Infinito\Exception\AllreadySetException;
use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\NotSetException;
use Infinito\Exception\NoValidChoiceException;
use Doctrine\Common\Collections\Collection;
use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\NotCorrectInstanceException;
use Infinito\Entity\EntityInterface;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Type\InvalidChoiceTypeException;
use Infinito\Exception\Validation\ValueInvalidException;
use Infinito\Logic\Result\ResultInterface;
use Symfony\Component\Intl\Exception\NotImplementedException;
@@ -48,12 +48,11 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
/**
* @param string $actionType
*
* @throws NoValidChoiceException
* @throws InvalidChoiceTypeException
*/
private function throwNoValidActionTypeException(string $actionType): void
{
throw new NoValidChoiceException("The action type <<$actionType>> is not defined and not valid!");
throw new InvalidChoiceTypeException("The action type <<$actionType>> is not defined and not valid!");
}
/**
@@ -82,36 +81,36 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
* @param string $actionType
* @param mixed $data
*
* @throws NotCorrectInstanceException For false a exception is thrown
* @throws ValueInvalidException For false a exception is thrown
*/
private function validateActionData(string $actionType, $data): void
{
if (!$this->isValidActionData($actionType, $data)) {
throw new NotCorrectInstanceException('Data <<'.gettype($data).(is_object($data) ? ':'.get_class($data) : '').">> is not valid for action type <<$actionType>>!");
throw new ValueInvalidException('Data <<'.gettype($data).(is_object($data) ? ':'.get_class($data) : '').">> is not valid for action type <<$actionType>>!");
}
}
/**
* @param string $actionType
*
* @throws NotSetException
* @throws ContainsElementException
*/
private function validateNotSet(string $actionType): void
{
if ($this->isDataStored($actionType)) {
throw new AllreadySetException("Data for <<$actionType>> is allready stored.");
throw new ContainsElementException("Data for <<$actionType>> is allready stored.");
}
}
/**
* @param string $actionType
*
* @throws NotSetException
* @throws NotSetElementException
*/
private function validateSet(string $actionType): void
{
if (!$this->isDataStored($actionType)) {
throw new NotSetException("No data for <<$actionType>> is stored.");
throw new NotSetElementException("No data for <<$actionType>> is stored.");
}
}

View File

@@ -6,10 +6,10 @@ use Infinito\Entity\EntityInterface;
use Infinito\Domain\RightManagement\RightTransformerService;
use Doctrine\Common\Collections\Collection;
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;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
/**
* This class is not ready and not tested!
@@ -25,12 +25,12 @@ final class EntityDomService implements EntityDomServiceInterface
/**
* @var string
*/
const GET_METHOD = RightTransformerService::GET_PREFIX;
private const GET_METHOD = RightTransformerService::GET_PREFIX;
/**
* @var string
*/
const HAS_METHOD = RightTransformerService::HAS_PREFIX;
private const HAS_METHOD = RightTransformerService::HAS_PREFIX;
/**
* @var RequestedEntityServiceInterface
@@ -131,7 +131,7 @@ final class EntityDomService implements EntityDomServiceInterface
}
}
if (is_object($value)) {
throw new NotCorrectInstanceException('The instance '.get_class($value).' is not supported!');
throw new NotCorrectInstanceCoreException('The instance '.get_class($value).' is not supported!');
}
$domElement->setAttribute('type', gettype($value));
$domElement->setAttribute('value', $value);

View File

@@ -5,7 +5,7 @@ namespace Infinito\Domain\FormManagement;
use Symfony\Component\Form\FormBuilderInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
/**
* @author kevinfrantz

View File

@@ -4,7 +4,7 @@ namespace Infinito\Domain\LayerManagement;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Entity\Meta\Law;
use Infinito\Entity\Meta\Right;
use Infinito\Entity\Meta\Relation\Parent\HeredityRelation;

View File

@@ -4,7 +4,7 @@ namespace Infinito\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Request;
use Infinito\Exception\NotDefinedException;
use Infinito\Exception\Attribut\UndefinedAttributException;
/**
* This class exists out of refactoring reasons.
@@ -71,6 +71,6 @@ abstract class AbstractGetParameterService implements GetParameterServiceInterfa
if ($this->hasParameter($key)) {
return $this->currentRequest->get($key);
}
throw new NotDefinedException("The parameter <<$key>> is not defined!");
throw new UndefinedAttributException("The parameter <<$key>> is not defined!");
}
}

View File

@@ -3,7 +3,7 @@
namespace Infinito\Domain\ParameterManagement\Parameter;
use Symfony\Component\Validator\Constraints as Assert;
use Infinito\Exception\Validation\InvalidGetParameterException;
use Infinito\Exception\Validation\GetParameterInvalidException;
/**
* @author kevinfrantz
@@ -48,6 +48,6 @@ final class FrameParameter extends AbstractParameter
return;
}
}
throw new InvalidGetParameterException("It\'s not possible to set <<$value>> of type <<".$type.'>> for class <<'.get_class().'>>. Just 0 and 1 are allowed!');
throw new GetParameterInvalidException("It\'s not possible to set <<$value>> of type <<".$type.'>> for class <<'.get_class().'>>. Just 0 and 1 are allowed!');
}
}

View File

@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use HaydenPierce\ClassFinder\ClassFinder;
use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface;
use Infinito\Exception\NotDefinedException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @author kevinfrantz
@@ -67,7 +67,7 @@ final class ParameterFactory implements ParameterFactoryInterface
if ($parameter) {
return $parameter;
}
throw new NotDefinedException("The parameter for key <<$key>> doesn't exist! Generate a parameter class in the parameter folder!");
throw new NotSetElementException("The parameter for key <<$key>> doesn't exist! Generate a parameter class in the parameter folder!");
}
/**

View File

@@ -4,7 +4,6 @@ namespace Infinito\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Infinito\Exception\Validation\InvalidGetParameterException;
/**
* @author kevinfrantz

View File

@@ -6,7 +6,7 @@ use Doctrine\Common\Collections\Collection;
use Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
/**
* @author kevinfrantz

View File

@@ -8,16 +8,17 @@ use Infinito\Attribut\SlugAttribut;
use Infinito\Attribut\RequestedRightAttribut;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Infinito\Repository\Source\SourceRepositoryInterface;
use Infinito\Exception\NotCorrectInstanceException;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Exception\NotSetException;
use Infinito\Repository\RepositoryInterface;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Attribut\ClassAttribut;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService;
use Infinito\Exception\EntityNotFoundHttpException;
use Infinito\Exception\Attribut\UndefinedAttributException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\NotFound\EntityNotFoundException;
/**
* @author kevinfrantz
@@ -39,24 +40,24 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
private $layerRepositoryFactoryService;
/**
* @throws NotSetException
* @throws UndefinedAttributException
*/
private function validateHasIdentity(): void
{
if (!($this->hasId() || $this->hasSlug())) {
throw new NotSetException('No identity attribut like id or slug was set!');
throw new NoIdentityCoreException('No identity attribut like id or slug was set!');
}
}
/**
* @param EntityInterface|null $entity
* @param EntityInterface $entity
*
* @throws EntityNotFoundHttpException
* @throws EntityNotFoundException
*/
private function validateLoadedEntity(?EntityInterface $entity): void
{
if (!$entity) {
throw new EntityNotFoundHttpException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found');
throw new EntityNotFoundException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found');
}
}
@@ -72,18 +73,13 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
return $this->loadById();
}
/**
* @throws NotCorrectInstanceException
*
* @return SourceInterface|null
*/
private function loadBySlug(): ?SourceInterface
{
$repository = $this->getEntityRepository();
if ($repository instanceof SourceRepositoryInterface) {
return $repository->findOneBySlug($this->slug);
}
throw new NotCorrectInstanceException('To read an entity by slug is just allowed for entitys of type '.AbstractSource::class);
throw new NotCorrectInstanceCoreException('To read an entity by slug is just allowed for entitys of type '.AbstractSource::class);
}
/**
@@ -97,12 +93,12 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
}
/**
* @throws NotSetException
* @throws UndefinedAttributException
*/
private function validateLayerRepositoryFactoryService(): void
{
if (!$this->layerRepositoryFactoryService) {
throw new NotSetException('The operation is not possible, because the class '.LayerRepositoryFactoryService::class.' is not injected!');
throw new UndefinedAttributException('The operation is not possible, because the class '.LayerRepositoryFactoryService::class.' is not injected!');
}
}
@@ -152,7 +148,7 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
public function setIdentity($identity): void
{
if ($this->hasClass()) {
throw new AllreadyDefinedException('A identity can\'t be set if a class is allready defined!');
throw new AllreadyDefinedAttributException('A identity can\'t be set if a class is allready defined!');
}
if (is_numeric($identity)) {
$this->setId($identity);
@@ -172,7 +168,7 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
public function setClass(string $class): void
{
if ($this->hasIdentity()) {
throw new AllreadyDefinedException('A class can\'t be manual defined, if an identity is allready set!');
throw new AllreadyDefinedAttributException('A class can\'t be manual defined, if an identity is allready set!');
}
$this->setClassTrait($class);
}

View File

@@ -5,14 +5,14 @@ namespace Infinito\Domain\RequestManagement\Right;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Attribut\LayerAttribut;
use Infinito\Attribut\RecieverAttribut;
use Infinito\Exception\PreconditionFailedException;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Attribut\RequestedEntityAttribut;
use Infinito\Entity\Meta\MetaInterface;
use Infinito\Exception\NotCorrectInstanceException;
use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
use Infinito\Attribut\ActionTypeAttribut;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\NoIdentityCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
/**
* @author kevinfrantz
@@ -31,7 +31,7 @@ class RequestedRight implements RequestedRightInterface
private $source;
/**
* @throws NotCorrectInstanceException
* @throws NotCorrectInstanceCoreException
*/
private function loadSource(): void
{
@@ -46,18 +46,18 @@ class RequestedRight implements RequestedRightInterface
return;
}
throw new NotCorrectInstanceException('The entity instance '.get_class($entity).' can\'t be processed');
throw new NotCorrectInstanceCoreException('The entity instance '.get_class($entity).' can\'t be processed');
}
/**
* @throws PreconditionFailedException If the source has no id or slug
* @throws NoIdentityCoreException If the source has no id or slug
*/
private function validateRequestedEntity(): void
{
if ($this->requestedEntity->hasIdentity()) {
return;
}
throw new PreconditionFailedException(get_class($this->requestedEntity).' needs to have a defined attribut id or slug!');
throw new NoIdentityCoreException(get_class($this->requestedEntity).' needs to have a defined attribut id or slug!');
}
/**
@@ -79,7 +79,7 @@ class RequestedRight implements RequestedRightInterface
public function setActionType(string $actionType): void
{
if (isset($this->actionType)) {
throw new AllreadySetException("The action type is allready set! Origine: $this->actionType New: $actionType");
throw new AllreadyDefinedAttributException("The action type is allready set! Origine: $this->actionType New: $actionType");
}
$this->setActionTypeTrait($actionType);
}

View File

@@ -14,17 +14,17 @@ final class RightTransformerService implements RightTransformerServiceInterface
/**
* @var string Prefix for setter functions
*/
const SET_PREFIX = 'set';
public const SET_PREFIX = 'set';
/**
* @var string Prefix for getter functions
*/
const GET_PREFIX = 'get';
public const GET_PREFIX = 'get';
/**
* @var string Prefix for has functions
*/
const HAS_PREFIX = 'has';
public const HAS_PREFIX = 'has';
/**
* @param string $method

View File

@@ -8,7 +8,7 @@ use Infinito\Exception\AllreadySetException;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Meta\Law;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
use Doctrine\Common\Collections\ArrayCollection;
/**

View File

@@ -5,7 +5,7 @@ namespace Infinito\Domain\SourceManagement;
use Infinito\Entity\Meta\RightInterface;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
/**
* Allows to add and remove rights of a source.

View File

@@ -3,7 +3,7 @@
namespace Infinito\Domain\TwigManagement;
use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
/**
* @author kevinfrantz

View File

@@ -2,7 +2,7 @@
namespace Infinito\Domain\TwigManagement;
use Infinito\Exception\NotSetException;
use Infinito\Exception\Collection\NotSetException;
use Infinito\DBAL\Types\Meta\Right\LayerType;
/**