You are here

public function EntityMatcher::getSummary in Linkit 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/Linkit/Matcher/EntityMatcher.php \Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher::getSummary()

Returns the summarized configuration of the matcher.

Return value

array An array of summarized configuration of the matcher.

Overrides MatcherBase::getSummary

3 calls to EntityMatcher::getSummary()
FileMatcher::getSummary in src/Plugin/Linkit/Matcher/FileMatcher.php
Returns the summarized configuration of the matcher.
NodeMatcher::getSummary in src/Plugin/Linkit/Matcher/NodeMatcher.php
Returns the summarized configuration of the matcher.
UserMatcher::getSummary in src/Plugin/Linkit/Matcher/UserMatcher.php
Returns the summarized configuration of the matcher.
3 methods override EntityMatcher::getSummary()
FileMatcher::getSummary in src/Plugin/Linkit/Matcher/FileMatcher.php
Returns the summarized configuration of the matcher.
NodeMatcher::getSummary in src/Plugin/Linkit/Matcher/NodeMatcher.php
Returns the summarized configuration of the matcher.
UserMatcher::getSummary in src/Plugin/Linkit/Matcher/UserMatcher.php
Returns the summarized configuration of the matcher.

File

src/Plugin/Linkit/Matcher/EntityMatcher.php, line 140

Class

EntityMatcher
Provides default linkit matchers for all entity types.

Namespace

Drupal\linkit\Plugin\Linkit\Matcher

Code

public function getSummary() {
  $summery = parent::getSummary();
  $entity_type = $this->entityTypeManager
    ->getDefinition($this->targetType);
  $metadata = $this->configuration['metadata'];
  if (!empty($metadata)) {
    $summery[] = $this
      ->t('Metadata: @metadata', [
      '@metadata' => $metadata,
    ]);
  }
  if ($entity_type
    ->hasKey('bundle')) {
    $has_bundle_filter = !empty($this->configuration['bundles']);
    $bundles = [];
    if ($has_bundle_filter) {
      $bundles_info = $this->entityTypeBundleInfo
        ->getBundleInfo($this->targetType);
      foreach ($this->configuration['bundles'] as $bundle) {
        $bundles[] = $bundles_info[$bundle]['label'];
      }
    }
    $summery[] = $this
      ->t('Bundle filter: @bundle_filter', [
      '@bundle_filter' => $has_bundle_filter ? implode(', ', $bundles) : $this
        ->t('None'),
    ]);
    $summery[] = $this
      ->t('Group by bundle: @bundle_grouping', [
      '@bundle_grouping' => $this->configuration['group_by_bundle'] ? $this
        ->t('Yes') : $this
        ->t('No'),
    ]);
    if (!empty($this->configuration['limit'])) {
      $summery[] = $this
        ->t('Limit: @limit', [
        '@limit' => $this->configuration['limit'],
      ]);
    }
  }
  return $summery;
}