class PageRedirect in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/PageRedirect.php \Drupal\business_rules\Plugin\BusinessRulesAction\PageRedirect
Class PageRedirect.
@package Drupal\business_rules\Plugin\BusinessRulesAction
Plugin annotation
@BusinessRulesAction(
id = "page_redirect",
label = @Translation("Page redirect"),
group = @Translation("System"),
description = @Translation("Page redirect."),
isContextDependent = FALSE,
hasTargetEntity = FALSE,
hasTargetBundle = FALSE,
hasTargetField = FALSE,
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\business_rules\Plugin\BusinessRulesItemPluginBase implements BusinessRulesItemPluginInterface
- class \Drupal\business_rules\Plugin\BusinessRulesActionPlugin implements BusinessRulesActionPluginInterface
- class \Drupal\business_rules\Plugin\BusinessRulesAction\PageRedirect
- class \Drupal\business_rules\Plugin\BusinessRulesActionPlugin implements BusinessRulesActionPluginInterface
- class \Drupal\business_rules\Plugin\BusinessRulesItemPluginBase implements BusinessRulesItemPluginInterface
Expanded class hierarchy of PageRedirect
File
- src/
Plugin/ BusinessRulesAction/ PageRedirect.php, line 28
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionView source
class PageRedirect extends BusinessRulesActionPlugin {
/**
* {@inheritdoc}
*/
public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
$settings['url'] = [
'#type' => 'textfield',
'#title' => t('Url'),
'#required' => TRUE,
'#default_value' => $item
->getSettings('url'),
'#description' => t('The full url to redirect as "http://www.example.com/page" if it is external or the relative path if it is internal as "/node/1". You can use variables to compose the url.'),
];
return $settings;
}
/**
* {@inheritdoc}
*/
public function execute(ActionInterface $action, BusinessRulesEvent $event) {
$url = $action
->getSettings('url');
$url = $this
->processVariables($url, $event
->getArgument('variables'));
$redirect = new RedirectResponse($url);
$redirect
->send();
$result = [
'#type' => 'markup',
'#markup' => t('Page redirect to: %url.', [
'%url' => $url,
]),
];
return $result;
}
}