public function entityEventAction(EntityReflectionInterface $entity, $entity_method, EntityInterface $object = null, RepositoryDefinitionInterface $repository_definition, RepositoryInterface $repository)
    {
        if (null === $object) {
            throw new NotFoundHttpException();
        }

        // Get the Event
        $event = call_user_func([$object, $entity_method]);

        // We accept "null", in that case we do nothing, but no other objects
        if (null !== $event && ! $event instanceof EventInterface) {
            throw new DomainErrorException('An invalid Event was emitted by '.$entity->getName().' '.$entity_method.'. Maybe you forgot to implement EventInterface? Result must be either an implementation either null.');
        }

        if (! $repository instanceof ReceiveEventInterface) {
            throw new DomainErrorException('Repository for Entity '.$entity->getName().' can not receive Events. Maybe you forgot to implement ReceiveEventInterface?');
        }

        if (null !== $event) {
            call_user_func([$repository, 'receive'], $event);

            $this->get('session')->getFlashBag()->add(
                'success',
                'Success!'
            );
        }

        // We redirect to "listing" page/action
        $listRoute = $this->get('orchestra.resolver.repository_route_name')->getRouteName($repository_definition, 'listing');

        return $this->redirect($this->generateUrl($listRoute));
    }
public function entityEventAction(EntityReflectionInterface $entity, $entity_method, EntityInterface $object = null, RepositoryDefinitionInterface $repository_definition, RepositoryInterface $repository)
    {
        if (null === $object) {
            throw new NotFoundHttpException();
        }

        // Get the Event
        $event = call_user_func([$object, $entity_method]);

        // We accept "null", in that case we do nothing, but no other objects
        if (null !== $event && ! $event instanceof EventInterface) {
            throw new DomainErrorException('An invalid Event was emitted by '.$entity->getName().' '.$entity_method.'. Maybe you forgot to implement EventInterface? Result must be either an implementation either null.');
        }

        if (! $repository instanceof ReceiveEventInterface) {
            throw new DomainErrorException('Repository for Entity '.$entity->getName().' can not receive Events. Maybe you forgot to implement ReceiveEventInterface?');
        }

        if (null !== $event) {
            call_user_func([$repository, 'receive'], $event);

            $this->get('session')->getFlashBag()->add(
                'success',
                'Success!'
            );
        }

        // We redirect to "listing" page/action
        $listRoute = $this->get('orchestra.resolver.repository_route_name')->getRouteName($repository_definition, 'listing');

        return $this->redirect($this->generateUrl($listRoute));
    }
public function entityEventAction ( EntityReflectionInterface $ entity , $ entity_method , EntityInterface $ object = null , RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository ) { if ( null === $ object ) { throw new NotFoundHttpException ( ) ; } // Get the Event $ event = call_user_func ( [ $ object , $ entity_method ] ) ; // We accept "null", in that case we do nothing, but no other objects if ( null !== $ event && ! $ event instanceof EventInterface ) { throw new DomainErrorException ( 'An invalid Event was emitted by ' . $ entity -> getName ( ) . ' ' . $ entity_method . '. Maybe you forgot to implement EventInterface? Result must be either an implementation either null.' ) ; } if ( ! $ repository instanceof ReceiveEventInterface ) { throw new DomainErrorException ( 'Repository for Entity ' . $ entity -> getName ( ) . ' can not receive Events. Maybe you forgot to implement ReceiveEventInterface?' ) ; } if ( null !== $ event ) { call_user_func ( [ $ repository , 'receive' ] , $ event ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Success!' ) ; } // We redirect to "listing" page/action $ listRoute = $ this -> get ( 'orchestra.resolver.repository_route_name' ) -> getRouteName ( $ repository_definition , 'listing' ) ; return $ this -> redirect ( $ this -> generateUrl ( $ listRoute ) ) ; }
Action used when a method with a "EmitEvent" annotations is called

@param EntityReflectionInterface $entity
@param string $entity_method
@param EntityInterface $object
@param RepositoryDefinitionInterface $repository_definition
@param RepositoryInterface $repository
@throws DomainErrorException
@throws NotFoundHttpException
@return \Symfony\Component\HttpFoundation\Response
Action used when a method with a EmitEvent annotations is called