You are here

public function FlowPull::pull in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/Controller/FlowPull.php \Drupal\cms_content_sync\Controller\FlowPull::pull()
  2. 2.0.x src/Controller/FlowPull.php \Drupal\cms_content_sync\Controller\FlowPull::pull()

Pull all entities of this Flow.

Parameters

$cms_content_sync_flow:

$pull_mode:

Return value

null|\Symfony\Component\HttpFoundation\RedirectResponse

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'FlowPull::pull'
cms_content_sync.routing.yml in ./cms_content_sync.routing.yml
cms_content_sync.routing.yml

File

src/Controller/FlowPull.php, line 33

Class

FlowPull
Pull controller.

Namespace

Drupal\cms_content_sync\Controller

Code

public function pull($cms_content_sync_flow, $pull_mode) {

  /**
   * @var \Drupal\cms_content_sync\Entity\Flow $flow
   */
  $flow = \Drupal::entityTypeManager()
    ->getStorage('cms_content_sync_flow')
    ->load($cms_content_sync_flow);
  $force_pull = false;
  if ('all_entities' == $pull_mode) {
    $force_pull = true;
  }
  $result = FlowPull::pullAll($flow, $force_pull);
  $operations = [];
  foreach ($result as $id => $operation) {
    $operations[] = [
      '\\Drupal\\cms_content_sync\\Controller\\FlowPull::batch',
      [
        $operation,
      ],
    ];
  }
  $batch = [
    'title' => t('Pull all'),
    'operations' => $operations,
    'finished' => '\\Drupal\\cms_content_sync\\Controller\\FlowPull::batchFinished',
  ];
  batch_set($batch);
  return batch_process(Url::fromRoute('entity.cms_content_sync_flow.collection'));
}