You are here

Block.html.twig in Drupal 7 to 8/9 Module Upgrader 8

Contains \Drupal\{{ module }}\Plugin\Block\{{ class }}.

File

templates/Block.html.twig
View source
  1. /**
  2. * @file
  3. * Contains \Drupal\{{ module }}\Plugin\Block\{{ class }}.
  4. */
  5. namespace Drupal\{{ module }}\Plugin\Block;
  6. use Drupal\Core\Block\BlockBase;
  7. {% if configurable %}
  8. use Drupal\Core\Form\FormStateInterface;
  9. {% endif %}
  10. /**
  11. * Provides the {{ class }} block.
  12. *
  13. * @Block(
  14. * id = "{{ module }}_{{ block_id }}",
  15. * admin_label = @Translation("{{ block_label }}")
  16. * )
  17. */
  18. class {{ class }} extends BlockBase {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function build() {
  23. /**
  24. * @FIXME
  25. * hook_block_view() has been removed in Drupal 8. You should move your
  26. * block's view logic into this method and delete {{ module }}_block_view()
  27. * as soon as possible!
  28. */
  29. return {{ module }}_block_view('{{ block_id }}');
  30. }
  31. {% if configurable %}
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function blockForm($form, FormStateInterface $form_state) {
  36. /**
  37. * @FIXME
  38. * hook_block_configure() is gone in Drupal 8. You should move your block's
  39. * configuration logic into this method and delete {{ module }}_block_configure()
  40. * as soon as possible!
  41. */
  42. return {{ module }}_block_configure('{{ block_id }}');
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function blockSubmit($form, FormStateInterface $form_state) {
  48. /**
  49. * @FIXME
  50. * hook_block_save() is gone in Drupal 8. You should move your block's save
  51. * logic into this method and delete {{ module }}_block_save() as soon as
  52. * possible!
  53. */
  54. return {{ module }}_block_save('{{ block_id }}', $form_state->getValues());
  55. }
  56. {% endif %}
  57. }