Finish batch.

@param bool $success
Status.
@param array $results
Results.
@param array $operations
Operations.

@return \Symfony\Component\HttpFoundation\RedirectResponse
Redirect response.
329938
public static function deleteAllMembersFinishBatch($success, $results, $operations) {
    $message = t('Finished with an error.');
    if ($success) {
      $message = \Drupal::translation()
        ->formatPlural(count($results), 'Removed one item.', 'Removed @count items.');
    }
    drupal_set_message($message);

    $url = Url::fromRoute('entity.openy_campaign_member.collection');

    return new RedirectResponse($url->toString());
  }
1262169
public function finish($results)
    {
        $process = new Process($this->generateConsoleCommand($results, true));

        $process->run(function ($type, $output)
        {
            $this->command->line($output);
        });

        return ! (bool) $process->getExitCode();
    }
1270663
private function doAfterQuery($result, $methodName, $arguments)
    {
        $traits = $this->getUsedTraits();

        if (in_array(CacheResults::class, $traits)) {
            // Reset caching to enabled in case it has just been disabled.
            $this->caching = true;
        }

        if (in_array(ThrowsHttpExceptions::class, $traits)) {

            if ($this->shouldThrowHttpException($result, $methodName)) {
                $this->throwNotFoundHttpException($methodName, $arguments);
            }

            $this->exceptionsDisabled = false;
        }

        return $result;
    }
893154
protected function validateTaskResult(Result $result)
    {
        if ($result->getExitCode() !== Result::EXITCODE_OK) {
            throw new TaskResultRuntimeException($result);
        }

        return $result;
    }
957533
public function handleBatchDeleteForm(FormInterface $form, $entities, $successMessage = 'crud.action.batch_delete.success')
    {
        if (!$form->isValid()) {
            $message = implode(PHP_EOL, array_map(function (FormError $error) {
                return $error->getMessage();
            }, iterator_to_array($form->getErrors(true))));
            $this->flashNotifier->error($message);

            return false;
        }
        foreach ($entities as $entity) {
            $this->em->remove($entity);
        }

        $this->em->flush();

        $this->flashNotifier->success($successMessage);

        return true;
    }
842746
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
401391
public function processResult(array $result) {
        list($result, $isRaw) = array_values($result);

        if(!$isRaw && is_string($result)) {
            return $this->createClone($result);
        }

        return $result;
    }
881265
protected function finalize($jobResults)
    {
        foreach ($jobResults as $jobResult) {
            if ($jobResult->error) {
                foreach ($this->plugins as $plugin) {
                    $plugin->onError($jobResult->error, [$jobResult->originalJob]);
                }
            }
        }

        foreach ($jobResults as $id => $jobResult) {
            if ($jobResult->success) {
                foreach ($this->plugins as $plugin) {
                    $plugin->onSuccess($jobResult);
                }
            }
        }

        foreach ($this->plugins as $plugin) {
            $jobResults = $plugin->afterResponse($jobResults);
        }

        $response = new Response();
        $response->results = $jobResults;

        return $response;
    }
884330
protected function cacheResults(array $results)
    {
        $mapper = $this->mapper;

        // When hydrating EmbeddedValue object, they'll likely won't
        // have a primary key set.
        if ($mapper->getEntityMap()->getKeyName() !== null) {
            $mapper->getEntityCache()->add($results);
        }
    }
850338
public function finish(array $items = []): bool
    {
        $changed = false;

        foreach ($items as $key => $value) {
            $serialized = \serialize($value);

            if (! $this->check($key, $serialized)) {
                $changed = true;

                try {
                    $this->saving($key, $serialized, $this->isNewKey($key));
                } catch (PDOException $e) {
                    // Should be able to ignore failure since it is possible that
                    // the request is done on a read only connection.
                }
            }
        }

        if ($changed && $this->cache instanceof Repository) {
            $this->cache->forget($this->cacheKey);
        }

        return true;
    }
1251878
private function isSent($results)
    {
        return array_key_exists(self::MESSAGE_ID, $results) && !array_key_exists(self::REGISTRATION_ID, $results);
    }
748213
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClass());
    }
285776
public function finishProcessing(\ArrayObject $jobs)
    {
        foreach ($jobs as $job) {
            $job->setStatus(JobInterface::STATUS_ACTIVE);
        }

        $this->em->flush();

        return $this;
    }
1335458
private function resultToResponse($result) : Response
  {
    switch (true) {
      // Response object
      case $result instanceof Response:
        return $result;
      // String -> transform to response
      case is_string($result) || is_numeric($result):
        return new Response($result);
      // Uri -> transform to redirect response
      case $result instanceof Uri:
        return new RedirectResponse($uri);
      // Array -> transform to json response
      case is_array($result) || is_object($result):
        return new JsonResponse($result);
      default:
        throw new \InvalidArgumentException('Invalid route handler return value');
    }
  }
471595
public function setResult($jobname, $result = null)
    {
        if (isset($this->results[$jobname])) {
            return false;
        }
        $this->results[$jobname] = $result;
        ++$this->resultsNum;
        $this->checkIfAllReady();
        return true;
    }
381452
private function iteratorFromResults(array $results)
    {
        $values = [];

        foreach ($results as $item) {
            $entry = new IndexEntry();

            $entry->indexKey  = key($item);
            $entry->objectKey = reset($item);

            $values[] = $entry;
        }

        return new ArrayIterator($values);
    }
1018423
protected function checkStrategiesResults($results)
    {
        $results = array_filter($results, function ($value) {
            return $value !== false && (!is_string($value) || mb_strpos($value, 'not found') === false);
        });

        return count($results) === count($this->strategies);
    }