Broken.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Drupal\Core\Block\Plugin\Block;
  3. use Drupal\Core\Block\BlockPluginInterface;
  4. use Drupal\Core\Block\BlockPluginTrait;
  5. use Drupal\Core\Cache\CacheableDependencyTrait;
  6. use Drupal\Core\Form\FormStateInterface;
  7. use Drupal\Core\Plugin\PluginBase;
  8. /**
  9. * Defines a fallback plugin for missing block plugins.
  10. *
  11. * @Block(
  12. * id = "broken",
  13. * admin_label = @Translation("Broken/Missing"),
  14. * category = @Translation("Block"),
  15. * )
  16. */
  17. class Broken extends PluginBase implements BlockPluginInterface {
  18. use BlockPluginTrait;
  19. use CacheableDependencyTrait;
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function build() {
  24. return $this->brokenMessage();
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function blockForm($form, FormStateInterface $form_state) {
  30. return $this->brokenMessage();
  31. }
  32. /**
  33. * Generate message with debugging information as to why the block is broken.
  34. *
  35. * @return array
  36. * Render array containing debug information.
  37. */
  38. protected function brokenMessage() {
  39. $build['message'] = [
  40. '#markup' => $this->t('This block is broken or missing. You may be missing content or you might need to enable the original module.'),
  41. ];
  42. return $build;
  43. }
  44. }