function EntityBundle::summary

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\EntityBundle::summary()
  2. 11.x core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\EntityBundle::summary()

Overrides ConditionInterface::summary

File

core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php, line 99

Class

EntityBundle
Provides the 'Entity Bundle' condition.

Namespace

Drupal\Core\Entity\Plugin\Condition

Code

public function summary() {
    if (count($this->configuration['bundles']) > 1) {
        $bundles = $this->configuration['bundles'];
        $last = array_pop($bundles);
        $bundles = implode(', ', $bundles);
        if (empty($this->configuration['negate'])) {
            return $this->t('@bundle_type is @bundles or @last', [
                '@bundle_type' => $this->pluginDefinition['label'],
                '@bundles' => $bundles,
                '@last' => $last,
            ]);
        }
        else {
            return $this->t('@bundle_type is not @bundles or @last', [
                '@bundle_type' => $this->pluginDefinition['label'],
                '@bundles' => $bundles,
                '@last' => $last,
            ]);
        }
    }
    $bundle = reset($this->configuration['bundles']);
    if (empty($this->configuration['negate'])) {
        return $this->t('@bundle_type is @bundle', [
            '@bundle_type' => $this->pluginDefinition['label'],
            '@bundle' => $bundle,
        ]);
    }
    else {
        return $this->t('@bundle_type is not @bundle', [
            '@bundle_type' => $this->pluginDefinition['label'],
            '@bundle' => $bundle,
        ]);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.