function EntityIsOfBundle::assertMetadata

Overrides RulesConditionBase::assertMetadata

File

src/Plugin/Condition/EntityIsOfBundle.php, line 65

Class

EntityIsOfBundle
Provides an 'Entity is of bundle' condition.

Namespace

Drupal\rules\Plugin\Condition

Code

public function assertMetadata(array $selected_data) {
  // Assert the checked bundle.
  $changed_definitions = [];
  if (isset($selected_data['entity']) && $bundle = $this->getContextValue('bundle')) {
    $changed_definitions['entity'] = clone $selected_data['entity'];
    $bundles = is_array($bundle) ? $bundle : [
      $bundle,
    ];
    $changed_definitions['entity']->setBundles($bundles);
  }
  return $changed_definitions;
}