You are here

public function ManualPull::access in CMS Content Sync 2.1.x

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

Ensure that the pull tab is just show if a flow exists which contains and entity type that has its pull set to "manual".

1 string reference to 'ManualPull::access'
cms_content_sync.routing.yml in ./cms_content_sync.routing.yml
cms_content_sync.routing.yml

File

src/Controller/ManualPull.php, line 22

Class

ManualPull
Provides a listing of Flow.

Namespace

Drupal\cms_content_sync\Controller

Code

public function access() {
  $flows = Flow::getAll();
  $manually_pulled_entity_types = [];
  foreach ($flows as $flow) {
    $pull_manually = $flow
      ->getController()
      ->getEntityTypesToPull(PullIntent::PULL_MANUALLY);
    if (!empty($pull_manually)) {
      $manually_pulled_entity_types[$flow
        ->id()] = $pull_manually;
    }
  }
  return AccessResult::allowedIf(!empty($manually_pulled_entity_types))
    ->addCacheableDependency($flows);
}