public function BehaviorInvoker::getBehaviorPlugin in Rabbit Hole 2.x
Same name and namespace in other branches
- 8 src/BehaviorInvoker.php \Drupal\rabbit_hole\BehaviorInvoker::getBehaviorPlugin()
Get the behavior plugin for the given entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to apply rabbit hole behavior on.
Return value
\Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase|null Rabbit Hole action plugin or NULL.
Overrides BehaviorInvokerInterface::getBehaviorPlugin
1 call to BehaviorInvoker::getBehaviorPlugin()
- BehaviorInvoker::processEntity in src/
BehaviorInvoker.php - Invoke a rabbit hole behavior based on an entity's configuration.
File
- src/
BehaviorInvoker.php, line 245
Class
- BehaviorInvoker
- Default implementation of Rabbit Hole behaviors invoker.
Namespace
Drupal\rabbit_holeCode
public function getBehaviorPlugin(ContentEntityInterface $entity) {
$values = $this
->getRabbitHoleValuesForEntity($entity);
$permission = 'rabbit hole bypass ' . $entity
->getEntityTypeId();
$values['bypass_access'] = $this->currentUser
->hasPermission($permission);
// Allow altering Rabbit Hole values.
$this->moduleHandler
->alter('rabbit_hole_values', $values, $entity);
// Do nothing if action is missing or access is bypassed.
if (empty($values['rh_action']) || $values['bypass_access']) {
return NULL;
}
return $this->rhBehaviorPluginManager
->createInstance($values['rh_action'], $values);
}