/**
  * Specific annotation evaluation.
  *
  * @param Request          $request    Request
  * @param Annotation       $annotation Annotation
  * @param ReflectionMethod $method     Method
  *
  * @return EntityAnnotationResolver self Object
  *
  * @throws EntityNotFoundException
  */
 public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method)
 {
     /**
      * Annotation is only loaded if is typeof AnnotationEntity
      */
     if ($annotation instanceof AnnotationEntity) {
         /**
          * Creating new instance of desired entity
          */
         $entity = $this->entityProvider->provide($annotation->getClass());
         /**
          * Tries to get a mapped instance of this entity.
          * If not mapped, just return old new created
          */
         $entity = $this->evaluateMapping($annotation, $entity);
         /**
          * Persists entity if defined
          */
         $this->resolvePersist($annotation, $entity);
         /**
          * If is decided this entity has to be persisted into manager
          */
         $this->evaluateSetters($request->attributes, $entity, $annotation->getSetters());
         /**
          * Get the parameter name. If not defined, is set as defined in
          * parameters
          */
         $parameterName = $annotation->getName() ?: $this->defaultName;
         $request->attributes->set($parameterName, $entity);
     }
     return $this;
 }
 /**
  * Specific annotation evaluation.
  *
  * @param Request          $request    Request
  * @param Annotation       $annotation Annotation
  * @param ReflectionMethod $method     Method
  *
  * @return EntityAnnotationResolver self Object
  *
  * @throws EntityNotFoundException
  */
 public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method)
 {
     /**
      * Annotation is only laoded if is typeof AnnotationEntity
      */
     if ($annotation instanceof AnnotationObjectManager) {
         /**
          * Creating new instance of desired entity
          */
         $entity = $this->entityProvider->provide($annotation->getClass());
         $objectManager = $this->doctrine->getManagerForClass(get_class($entity));
         /**
          * Get the parameter name. If not defined, is set as defined in
          * parameters
          */
         $parameterName = $annotation->getName() ?: $this->defaultName;
         $request->attributes->set($parameterName, $objectManager);
     }
     return $this;
 }
 /**
  * Specific annotation evaluation
  *
  * All method code will executed only if specific active flag is true
  *
  * @param Request          $request    Request
  * @param Annotation       $annotation Annotation
  * @param ReflectionMethod $method     Method
  *
  * @return AnnotationResolverInterface|string self Object or dql
  */
 public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method)
 {
     /**
      * Annotation is only loaded if is type-of AnnotationEntity
      */
     if ($annotation instanceof AnnotationPaginator) {
         /**
          * Creating new instance of desired entity
          */
         $entity = $this->entityProvider->provide($annotation->getClass());
         /**
          * We create a basic query builder
          */
         $queryBuilder = $this->createQueryBuilder($entity);
         /**
          * Every paginator evaluator is evaluated in this code.
          *
          * Every evaluated is defined using a Dependency Injection tag,
          * and accumulated in a Collector.
          * This collector evaluator, evaluates each one injected previously
          * by the DI Component
          */
         $this->paginatorEvaluatorCollector->evaluate($queryBuilder, $annotation);
         $paginator = new Paginator($queryBuilder, true);
         /**
          * Calculating limit of elements per page. Value can be evaluated
          * using as reference a Request attribute value
          */
         $limitPerPage = (int) $this->requestParameterProvider->getParameterValue($annotation->getLimit() ?: $this->defaultLimitPerPage);
         /**
          * Calculating page to fetch. Value can be evaluated using as
          * reference a Request attribute value
          */
         $page = (int) $this->requestParameterProvider->getParameterValue($annotation->getPage() ?: $this->defaultPage);
         /**
          * If attributes is not null, this bundle will place in the method
          * parameter named as defined a new PaginatorAttributes Value Object
          * with all needed data
          */
         $this->evaluateAttributes($request, $annotation, $paginator, $limitPerPage, $page);
         /**
          * Calculating offset, given number per pageand page
          */
         $offset = $limitPerPage * ($page - 1);
         /**
          * Retrieving the Paginator iterator
          */
         $paginator->getQuery()->setFirstResult($offset)->setMaxResults($limitPerPage);
         /**
          * Get the parameter name. If not defined, is set as defined in
          * parameters
          */
         $parameterName = $annotation->getName() ?: $this->defaultName;
         $parameterType = $this->getParameterType($method, $parameterName);
         $dql = $paginator->getQuery()->getDQL();
         $paginator = $this->decidePaginatorFormat($paginator, $parameterType, $limitPerPage, $page);
         $request->attributes->set($parameterName, $paginator);
         return $dql;
     }
     return $this;
 }
 /**
  * Testing class provider with good results
  *
  * @dataProvider dataProvide
  */
 public function testProvide($entityDefinition)
 {
     $this->assertInstanceOf($this->entityNamespace, $this->entityProvider->provide($entityDefinition));
 }