/** * Specific annotation evaluation. * * @param Request $request Request * @param Annotation $annotation Annotation * @param ReflectionMethod $method Method * * @return FormAnnotationResolver self Object */ public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method) { /** * Annotation is only laoded if is typeof WorkAnnotation */ if ($annotation instanceof AnnotationForm) { /** * Once loaded Annotation info, we just instanced Service name */ $annotationValue = $annotation->getClass(); /** * Get FormType object given a service name */ $type = class_exists($annotationValue) ? new $annotationValue() : $this->formRegistry->getType($annotationValue)->getInnerType(); /** * Get the parameter name. If not defined, is set as $form */ $parameterName = $annotation->getName() ?: $this->defaultName; $parameterClass = $this->getParameterType($method, $parameterName, 'Symfony\\Component\\Form\\FormInterface'); /** * Requiring result with calling getBuiltObject(), set as request * attribute desired element */ $request->attributes->set($parameterName, $this->getBuiltObject($request, $this->formFactory, $annotation, $parameterClass, $type)); } return $this; }
/** * Specific annotation evaluation. * * This method must be implemented in every single EventListener * with specific logic * * 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 self Object */ public function evaluateAnnotation(Request $request, Annotation $annotation, ReflectionMethod $method) { /** * Annotation is only loaded if is typeof AnnotationEntity */ if ($annotation instanceof Post) { $param = $request->request->get($annotation->getPath(), $annotation->getDefault(), $annotation->isDeep()); $annotationParameterName = $annotation->getName(); $parameterName = is_null($annotationParameterName) ? $annotation->getPath() : $annotationParameterName; $request->attributes->set($parameterName, $param); } }
/** * 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; }