public function repositoryCommandAction(Request $request, RepositoryDefinitionInterface $repository_definition, RepositoryInterface $repository, $repository_method, CommandInterface $command)
    {
        $form = $this->createForm('orchestra_command_type', $command, [
            'command' => $command
        ]);

        $repoName = $this->get('orchestra.resolver.repository_name')->getName($repository_definition);

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

                $this->get('session')->getFlashBag()->add(
                    'success',
                    'Command run with success!'
                );

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

                return $this->redirect($this->generateUrl($listRoute));
            } else {
                $this->get('session')->getFlashBag()->add(
                    'error',
                    'An error happened!'
                );
            }
        }

        return $this->render('RomaricDrigonOrchestraBundle:Generic:repositoryCommand.html.twig', [
            'form'  => $form->createView(),
            'title' => $repoName
        ]);
    }
public function repositoryCommandAction(Request $request, RepositoryDefinitionInterface $repository_definition, RepositoryInterface $repository, $repository_method, CommandInterface $command)
    {
        $form = $this->createForm('orchestra_command_type', $command, [
            'command' => $command
        ]);

        $repoName = $this->get('orchestra.resolver.repository_name')->getName($repository_definition);

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

                $this->get('session')->getFlashBag()->add(
                    'success',
                    'Command run with success!'
                );

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

                return $this->redirect($this->generateUrl($listRoute));
            } else {
                $this->get('session')->getFlashBag()->add(
                    'error',
                    'An error happened!'
                );
            }
        }

        return $this->render('RomaricDrigonOrchestraBundle:Generic:repositoryCommand.html.twig', [
            'form'  => $form->createView(),
            'title' => $repoName
        ]);
    }
public function repositoryCommandAction ( Request $ request , RepositoryDefinitionInterface $ repository_definition , RepositoryInterface $ repository , $ repository_method , CommandInterface $ command ) { $ form = $ this -> createForm ( 'orchestra_command_type' , $ command , [ 'command' => $ command ] ) ; $ repoName = $ this -> get ( 'orchestra.resolver.repository_name' ) -> getName ( $ repository_definition ) ; if ( $ request -> isMethod ( 'POST' ) ) { if ( $ form -> handleRequest ( $ request ) && $ form -> isValid ( ) ) { // Pass the command to the repository, and we're done! call_user_func ( [ $ repository , $ repository_method ] , $ command ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Command run with success!' ) ; // We redirect to "listing" page/action $ listRoute = $ this -> get ( 'orchestra.resolver.repository_route_name' ) -> getRouteName ( $ repository , 'listing' ) ; return $ this -> redirect ( $ this -> generateUrl ( $ listRoute ) ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , 'An error happened!' ) ; } } return $ this -> render ( 'RomaricDrigonOrchestraBundle:Generic:repositoryCommand.html.twig' , [ 'form' => $ form -> createView ( ) , 'title' => $ repoName ] ) ; }
Action used when a method accepting a Command, on en Repository is called

@param Request $request
@param RepositoryDefinitionInterface $repository_definition
@param RepositoryInterface $repository
@param string $repository_method
@param CommandInterface $command
@return \Symfony\Component\HttpFoundation\Response
Action used when a method accepting a Command on en Repository is called