Guest User

Untitled

a guest
Jan 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2. namespace Drupal\redirecting_path\Plugin\Block;
  3. use Drupal\Core\Block\BlockBase;
  4. use Drupal\Core\Form\FormBuilderInterface;
  5. use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
  6. use Symfony\Component\DependencyInjection\ContainerInterface;
  7. /**
  8. * Redirecting_block code.
  9. *
  10. * @Block(
  11. * id = "redirecting_path_block",
  12. * admin_label = @Translation("Redirecting Form Block"),
  13. * )
  14. */
  15. class RedirectingBlock extends BlockBase implements ContainerFactoryPluginInterface {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected $formBuilder;
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
  24. return new static(
  25. $configuration,
  26. $plugin_id,
  27. $plugin_definition,
  28. $container->get('form_builder')
  29. );
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $formBuilder) {
  35. parent::__construct($configuration, $plugin_id, $plugin_definition);
  36. $this->formBuilder = $formBuilder;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function build() {
  42. $form = $this->formBuilder->getForm('Drupal\redirecting_path\Form\RedirectingForm');
  43. return $form;
  44. }
  45. }
Add Comment
Please, Sign In to add comment