public function entityCommandAction(Request $request, CommandInterface $command, EntityReflectionInterface $entity, $entity_method, EntityInterface $object = null)
    {
        if (null === $object) {
            throw new NotFoundHttpException();
        }

        $form = $this->createForm('orchestra_command_type', $command, [
            'command' => $command
        ]);

        if ($request->isMethod('POST')) {
            if ($form->handleRequest($request) && $form->isValid()) {
                // Pass the command to the repository, and we're done!
                call_user_func([$object, $entity_method], $command);

                // We have to save the result!
                // We use our provided ObjectManager, not Doctrine
                $this->getObjectManager()->saveObject($object);

                $this->get('session')->getFlashBag()->add(
                    'success',
                    'Command run with success!'
                );
            } else {
                $this->get('session')->getFlashBag()->add(
                    'error',
                    'An error happened!'
                );
            }
        }

        return $this->render('RomaricDrigonOrchestraBundle:Generic:entityCommand.html.twig', [
            'form'  => $form->createView(),
            'title' => $entity->getName().' - '.$entity_method
        ]);
    }
public function entityCommandAction(Request $request, CommandInterface $command, EntityReflectionInterface $entity, $entity_method, EntityInterface $object = null)
    {
        if (null === $object) {
            throw new NotFoundHttpException();
        }

        $form = $this->createForm('orchestra_command_type', $command, [
            'command' => $command
        ]);

        if ($request->isMethod('POST')) {
            if ($form->handleRequest($request) && $form->isValid()) {
                // Pass the command to the repository, and we're done!
                call_user_func([$object, $entity_method], $command);

                // We have to save the result!
                // We use our provided ObjectManager, not Doctrine
                $this->getObjectManager()->saveObject($object);

                $this->get('session')->getFlashBag()->add(
                    'success',
                    'Command run with success!'
                );
            } else {
                $this->get('session')->getFlashBag()->add(
                    'error',
                    'An error happened!'
                );
            }
        }

        return $this->render('RomaricDrigonOrchestraBundle:Generic:entityCommand.html.twig', [
            'form'  => $form->createView(),
            'title' => $entity->getName().' - '.$entity_method
        ]);
    }
public function entityCommandAction ( Request $ request , CommandInterface $ command , EntityReflectionInterface $ entity , $ entity_method , EntityInterface $ object = null ) { if ( null === $ object ) { throw new NotFoundHttpException ( ) ; } $ form = $ this -> createForm ( 'orchestra_command_type' , $ command , [ 'command' => $ command ] ) ; if ( $ request -> isMethod ( 'POST' ) ) { if ( $ form -> handleRequest ( $ request ) && $ form -> isValid ( ) ) { // Pass the command to the repository, and we're done! call_user_func ( [ $ object , $ entity_method ] , $ command ) ; // We have to save the result! // We use our provided ObjectManager, not Doctrine $ this -> getObjectManager ( ) -> saveObject ( $ object ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Command run with success!' ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , 'An error happened!' ) ; } } return $ this -> render ( 'RomaricDrigonOrchestraBundle:Generic:entityCommand.html.twig' , [ 'form' => $ form -> createView ( ) , 'title' => $ entity -> getName ( ) . ' - ' . $ entity_method ] ) ; }
Action used when a method accepting a Command, on en Entity is called

@param Request $request
@param CommandInterface $command
@param EntityReflectionInterface $entity
@param string $entity_method
@param EntityInterface $object
@throws NotFoundHttpException
@return \Symfony\Component\HttpFoundation\Response
Action used when a method accepting a Command on en Entity is called