You are here

public function EntityMatcher::getSummary in Linkit 8.4

Same name and namespace in other branches
  1. 8.5 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 101
Contains \Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher.

Class

EntityMatcher
Plugin annotation @Matcher( id = "entity", label = @Translation("Entity"), deriver = "\Drupal\linkit\Plugin\Derivative\EntityMatcherDeriver" )

Namespace

Drupal\linkit\Plugin\Linkit\Matcher

Code

public function getSummary() {
  $summery = parent::getSummary();
  $entity_type = $this->entityManager
    ->getDefinition($this->target_type);
  $result_description = $this->configuration['result_description'];
  if (!empty($result_description)) {
    $summery[] = $this
      ->t('Result description: @result_description', [
      '@result_description' => $result_description,
    ]);
  }
  if ($entity_type
    ->hasKey('bundle')) {
    $has_bundle_filter = !empty($this->configuration['bundles']);
    $bundles = [];
    if ($has_bundle_filter) {
      $bundles_info = $this->entityManager
        ->getBundleInfo($this->target_type);
      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) : t('None'),
    ]);
    $summery[] = $this
      ->t('Group by bundle: @bundle_grouping', [
      '@bundle_grouping' => $this->configuration['group_by_bundle'] ? $this
        ->t('Yes') : $this
        ->t('No'),
    ]);
  }
  return $summery;
}