/**
   * Wraps all the available web segment.
   *
   * @param string $operation
   *   The entity operation to use this for. Defaults to 'view'.
   *
   * @return \Drupal\foo\WrappedEntities\WebSegment[]
   *   The web segments.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   * @throws \Drupal\typed_entity\InvalidValueException
   */
  public function wrapAll($operation = 'view'): array {
    $bundle_key = $this->entityType->getKey('bundle');
    $terms = $this->entityTypeManager
      ->getStorage($this->entityType->id())
      ->loadByProperties([$bundle_key => $this->bundle]);
    $check_access = static function (TermInterface $term) use ($operation) {
      return $term->access($operation);
    };
    $accessible_terms = array_filter($terms, $check_access);
    return $this->wrapMultiple($accessible_terms);
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

e0ipso created an issue. See original summary.

e0ipso’s picture

Issue summary: View changes
e0ipso’s picture

Status: Active » Reviewed & tested by the community
FileSize
1.75 KB
e0ipso’s picture

e0ipso’s picture

e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

  • e0ipso committed 48934d1 on 2.x
    Issue #3164332 by e0ipso: Add helper method wrapAll
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.