You are here

protected function PageRedirect::getFallbackAction in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php \Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPlugin\PageRedirect::getFallbackAction()

Returns the fallback action in case if action cannot be performed.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the action is being performed on.

Return value

string Fallback action name.

Overrides RabbitHoleBehaviorPluginBase::getFallbackAction

1 call to PageRedirect::getFallbackAction()
PageRedirect::performAction in src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php
Perform the rabbit hole action.

File

src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php, line 431

Class

PageRedirect
Redirects to another page.

Namespace

Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPlugin

Code

protected function getFallbackAction(EntityInterface $entity) {
  $fallback_action = $entity
    ->get('rh_redirect_fallback_action')->value;
  if (empty($fallback_action) || $fallback_action === 'bundle_default') {
    $bundle_settings = $this
      ->getBundleSettings($entity);
    $fallback_action = $bundle_settings
      ->get('redirect_fallback_action');
    $this->cacheMetadata
      ->addCacheableDependency($bundle_settings);
  }
  return !empty($fallback_action) ? $fallback_action : parent::getFallbackAction($entity);
}