class RedirectFormBlock

Same name in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php \Drupal\form_test\Plugin\Block\RedirectFormBlock
  2. 10 core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php \Drupal\form_test\Plugin\Block\RedirectFormBlock
  3. 11.x core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php \Drupal\form_test\Plugin\Block\RedirectFormBlock

Provides a block containing a simple redirect form.

Plugin annotation


@Block(
  id = "redirect_form_block",
  admin_label = @Translation("Redirecting form"),
  category = @Translation("Forms")
)

Hierarchy

Expanded class hierarchy of RedirectFormBlock

See also

\Drupal\form_test\Form\RedirectBlockForm

File

core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php, line 21

Namespace

Drupal\form_test\Plugin\Block
View source
class RedirectFormBlock extends BlockBase implements ContainerFactoryPluginInterface {
    
    /**
     * The form builder.
     *
     * @var \Drupal\Core\Form\FormBuilderInterface
     */
    protected $formBuilder;
    
    /**
     * Constructs a new RedirectFormBlock.
     *
     * @param array $configuration
     *   A configuration array containing information about the plugin instance.
     * @param string $plugin_id
     *   The plugin_id for the plugin instance.
     * @param mixed $plugin_definition
     *   The plugin implementation definition.
     * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
     *   The form builder.
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->formBuilder = $form_builder;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        return new static($configuration, $plugin_id, $plugin_definition, $container->get('form_builder'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function build() {
        return $this->formBuilder
            ->getForm('Drupal\\form_test\\Form\\RedirectBlockForm');
    }
    
    /**
     * {@inheritdoc}
     *
     * @todo Make cacheable once https://www.drupal.org/node/2351015 lands.
     */
    public function getCacheMaxAge() {
        return 0;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
RedirectFormBlock::$formBuilder protected property The form builder.
RedirectFormBlock::build public function
RedirectFormBlock::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
RedirectFormBlock::getCacheMaxAge public function @todo Make cacheable once https://www.drupal.org/node/2351015 lands.
RedirectFormBlock::__construct public function Constructs a new RedirectFormBlock.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.