Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Drupal\redirecting_path\Plugin\Block;
- use Drupal\Core\Block\BlockBase;
- use Drupal\Core\Form\FormBuilderInterface;
- use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
- use Symfony\Component\DependencyInjection\ContainerInterface;
- /**
- * Redirecting_block code.
- *
- * @Block(
- * id = "redirecting_path_block",
- * admin_label = @Translation("Redirecting Form Block"),
- * )
- */
- class RedirectingBlock extends BlockBase implements ContainerFactoryPluginInterface {
- /**
- * {@inheritdoc}
- */
- protected $formBuilder;
- /**
- * {@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 __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $formBuilder) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->formBuilder = $formBuilder;
- }
- /**
- * {@inheritdoc}
- */
- public function build() {
- $form = $this->formBuilder->getForm('Drupal\redirecting_path\Form\RedirectingForm');
- return $form;
- }
- }
Add Comment
Please, Sign In to add comment