main/core/Controller/ResourceController.php
public function executeCollectionAction($action, Request $request)
    {
        $ids = $request->query->get('ids');

        /** @var ResourceNode[] $resourceNodes */
        $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids);
        $responses = [];

        // read request and get user query
        $parameters = $request->query->all();
        $content = null;

        if (!empty($request->getContent())) {
            $content = json_decode($request->getContent(), true);
        }
        $files = $request->files->all();

        $this->om->startFlushSuite();

        foreach ($resourceNodes as $resourceNode) {
            // check the requested action exists
            if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) {
                // undefined action
                throw new NotFoundHttpException(
                    sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName())
                );
            }

            // check current user rights
            $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]);

            // dispatch action event
            $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files);
        }

        $this->om->endFlushSuite();

        return new JsonResponse(array_map(function (Response $response) {
            return json_decode($response->getContent(), true);
        }, $responses));
    }
public function executeCollectionAction($action, Request $request)
    {
        $ids = $request->query->get('ids');

        /** @var ResourceNode[] $resourceNodes */
        $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids);
        $responses = [];

        // read request and get user query
        $parameters = $request->query->all();
        $content = null;

        if (!empty($request->getContent())) {
            $content = json_decode($request->getContent(), true);
        }
        $files = $request->files->all();

        $this->om->startFlushSuite();

        foreach ($resourceNodes as $resourceNode) {
            // check the requested action exists
            if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) {
                // undefined action
                throw new NotFoundHttpException(
                    sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName())
                );
            }

            // check current user rights
            $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]);

            // dispatch action event
            $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files);
        }

        $this->om->endFlushSuite();

        return new JsonResponse(array_map(function (Response $response) {
            return json_decode($response->getContent(), true);
        }, $responses));
    }
public function executeCollectionAction ( $ action , Request $ request ) { $ ids = $ request -> query -> get ( 'ids' ) ; /** @var ResourceNode[] $resourceNodes */ $ resourceNodes = $ this -> om -> findList ( ResourceNode :: class , 'uuid' , $ ids ) ; $ responses = [ ] ; // read request and get user query $ parameters = $ request -> query -> all ( ) ; $ content = null ; if ( ! empty ( $ request -> getContent ( ) ) ) { $ content = json_decode ( $ request -> getContent ( ) , true ) ; } $ files = $ request -> files -> all ( ) ; $ this -> om -> startFlushSuite ( ) ; foreach ( $ resourceNodes as $ resourceNode ) { // check the requested action exists if ( ! $ this -> actionManager -> support ( $ resourceNode , $ action , $ request -> getMethod ( ) ) ) { // undefined action throw new NotFoundHttpException ( sprintf ( 'The action %s with method [%s] does not exist for resource type %s.' , $ action , $ request -> getMethod ( ) , $ resourceNode -> getResourceType ( ) -> getName ( ) ) ) ; } // check current user rights $ this -> checkAccess ( $ this -> actionManager -> get ( $ resourceNode , $ action ) , [ $ resourceNode ] ) ; // dispatch action event $ responses [ ] = $ this -> actionManager -> execute ( $ resourceNode , $ action , $ parameters , $ content , $ files ) ; } $ this -> om -> endFlushSuite ( ) ; return new JsonResponse ( array_map ( function ( Response $ response ) { return json_decode ( $ response -> getContent ( ) , true ) ; } , $ responses ) ) ; }
Executes an action on a collection of resources.

@EXT\Route("/collection/{action}", name="claro_resource_collection_action")

@param string  $action
@param Request $request

@return JsonResponse

@throws NotFoundHttpException
Executes an action on a collection of resources .