class GotoAction

Redirects to a different URL.

Plugin annotation


@Action(
  id = "action_goto_action",
  label = @Translation("Redirect to URL"),
  type = "system"
)

Hierarchy

Expanded class hierarchy of GotoAction

File

drupal/core/modules/action/lib/Drupal/action/Plugin/Action/GotoAction.php, line 23
Contains \Drupal\action\Plugin\Action\GotoAction.

Namespace

Drupal\action\Plugin\Action
View source
class GotoAction extends ConfigurableActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($object = NULL) {
    drupal_goto($this->configuration['url']);
  }

  /**
   * {@inheritdoc}
   */
  protected function getDefaultConfiguration() {
    return array(
      'url' => '',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function form(array $form, array &$form_state) {
    $form['url'] = array(
      '#type' => 'textfield',
      '#title' => t('URL'),
      '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like @url.', array(
        '@url' => 'http://drupal.org',
      )),
      '#default_value' => $this->configuration['url'],
      '#required' => TRUE,
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submit(array &$form, array &$form_state) {
    $this->configuration['url'] = $form_state['values']['url'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ActionBase::executeMultiple public function Executes the plugin for an array of objects. Overrides ActionInterface::executeMultiple 2
ConfigurableActionBase::getConfiguration public function Returns this plugin's configuration. Overrides ConfigurableActionInterface::getConfiguration
ConfigurableActionBase::validate public function Form validation handler. Overrides ConfigurableActionInterface::validate 2
ConfigurableActionBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct 3
ContainerFactoryPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 11
GotoAction::execute public function Executes the plugin. Overrides ExecutableInterface::execute
GotoAction::form public function Form constructor. Overrides ConfigurableActionInterface::form
GotoAction::getDefaultConfiguration protected function Returns default configuration for this action. Overrides ConfigurableActionBase::getDefaultConfiguration
GotoAction::submit public function Form submission handler. Overrides ConfigurableActionInterface::submit
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId