Issue a response to a batch action request.

@param callback $actionFunction the function that will be executed for
each of the selected IDs.
@param array $selectedIds the IDs on which the batch process must be
executed.
322006
protected function getBatchActionResponse($actionFunction, array $selectedIds)
    {
        $response = $this->getIndexRedirectionResponse();

        $successfullyUsedIds = array();
        foreach ($selectedIds as $id) {
            try {
                call_user_func($actionFunction, $id);
                $successfullyUsedIds[] = $id;
            } catch (NotFoundException $exception) {
                $response->addErrorMessage(sprintf(_('%s %s was not found.'),
                    _($this->getItemName()),
                    $id
                ));
            }
        }

        // TODO: Create a Report with the successfully used IDs.

        $response->addNotice(sprintf(_('%d %s were affected.'),
            count($successfullyUsedIds), _($this->getCollectionName())
        ));

        return $response;
    }
330788
protected void fireActionPerformed(ActionEvent event) {
    Object[] listeners = listenerList.getListenerList();
    for(int i = listeners.length - 2; i >= 0; i -= 2) {
      if(listeners[i] == ActionListener.class) {
        ((ActionListener) listeners[i + 1]).actionPerformed(event);
      }
    }
  }
1049785
private function refreshBatchesResult($listId, $batchesResult, &$batchesError)
    {
        $refreshedBatchsResults = [];
        foreach ($batchesResult as $key => $batch) {
            $jobId = $batch['JobID'];
            $batch = $this->synchronizer->getJob($listId, $jobId);
            // We need to array merge because Mailjet API doesn't send jobid in response.
            if ($batch[0]['Status'] == 'Error') {
                array_push($batchesError, array_merge(['JobID' => $jobId], $batch[0]));
            } else {
                array_push($refreshedBatchsResults, array_merge(['JobID' => $jobId], $batch[0]));
            }
        }
        return $refreshedBatchsResults;
    }
1155237
public function update($listId, Contact $contact, $action=Contact::ACTION_ADDNOFORCE)
    {
        $contact->setAction($action);
        $response = $this->_exec($listId, $contact);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:update() failed", $response);
        }

        return $response->getData();
    }
1011692
protected function actionListTransaction()
    {
        list($selected, $action) = $this->getPostedAction();

        $deleted = 0;

        foreach ($selected as $id) {

            if ($action === 'delete' && $this->access('transaction_delete')) {
                $deleted += (int) $this->transaction->delete($id);
            }
        }

        if ($deleted > 0) {
            $message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
            $this->setMessage($message, 'success');
        }
    }
295184
public function batchActionCopy(ProxyQueryInterface $selectedModelQuery)
    {
        if ($this->admin->isGranted('EDIT') === false) {
            throw new AccessDeniedException();
        }

        $pageHelper = $this->container->get('networking_init_cms.helper.page_helper');

        $selectedModels = $selectedModelQuery->execute();

        try {
            foreach ($selectedModels as $selectedModel) {
                /* @var PageInterface $selectedModel */
                $pageHelper->makePageCopy($selectedModel);
            }
        } catch (\Exception $e) {
            $this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_batch_copy_error');

            return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
        }

        $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_batch_copy_success');

        return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
    }
814206
def _handle_actiondefinefunction(self, _):
        """"""
        obj = _make_object("ActionDefineFunction")
        obj.FunctionName = self._get_struct_string()
        obj.NumParams = unpack_ui16(self._src)
        for i in range(1, obj.NumParams + 1):
            setattr(obj, "param" + str(i), self._get_struct_string())
        obj.CodeSize = unpack_ui16(self._src)
        yield obj
895301
public function handleEvent(ActionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $environment = $event->getEnvironment();
        $basic       = $environment->getDataDefinition()->getBasicDefinition();
        $action      = $event->getAction();

        if (null !== $event->getResponse()
            || ('showAll' !== $action->getName())
            || !$this->wantToHandle($basic->getMode(), $action)
        ) {
            return;
        }

        if (false !== ($response = $this->process($action, $environment))) {
            $event->setResponse($response);
        }
    }
1076104
public function process(ActionInterface $action, EntryCollection $collection): void
    {
        $invitee = $action->getComponent('directComplement')->getData();
        $collection->add(new EntryUnaware($this->resolveClass($invitee), $invitee->getId()));
    }
658870
public function executeCallback()
    {
        call_user_func_array(
            $this::getContainer()
                ->offsetGet('callback')
                ->get('action'),
            $this::getContainer()
                ->offsetGet('callback')
                ->get('params')
        );
    }
217682
public function batchActionEnable(ProxyQuery $selectedModelQuery, Request $request = null)
    {
        return $this->batchActionEnabled($selectedModelQuery, $request, true);
    }
1229502
public function execute(ResourceNode $resourceNode, string $actionName, array $options = [], array $content = null, array $files = null): Response
    {
        $resourceAction = $this->get($resourceNode, $actionName);
        $resource = $this->resourceManager->getResourceFromNode($resourceNode);

        /** @var ResourceActionEvent $event */
        $event = $this->dispatcher->dispatch(
            static::eventName($actionName, $resourceAction->getResourceType()),
            ResourceActionEvent::class,
            [$resource, $options, $content, $files, $resourceNode]
        );

        return $event->getResponse();
    }
465355
def handle_batch_multiple_actions
      # TODO: improve handling of errors in the batch response
      actions = []
      @batch.each do |action|
        actions << to_query(action[:params])
      end

      results = really_make_call({'method' => 'batch.run','methodFeed' => JSON.dump(actions)}, :post)
      @batch = nil
      extract_session_key results
      results
    end
955989
public function update($callbackId, CallbackBuilder $input, array $queryParams = [])
    {
        $response = $this->api->callbacks()->update($callbackId, $input->toArray(), $queryParams);

        return new CallbackResponse($response);
    }
1291767
public function _mergeAfterFetchWithSelectedKeys($result, $selectedKeys)
    {
        $this->_mergeAfterFetch($result, $selectedKeys ? empty($selectedKeys) : true);
        foreach ($selectedKeys as $key)
        {
            $this->dataAvailability[$key] = true;
        }
    }
1146448
public function batchActionDisable(ProxyQuery $selectedModelQuery, Request $request)
    {
        return $this->batchActionEnabled($selectedModelQuery, $request, false);
    }
1340231
protected function handleRequests()
    {
        $actions = array_keys($this->clientRequests);

        foreach ($actions as $actionName) {
            $this->dispatchRequestsForAction($actionName);
        }
    }