"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Block/Plugin/Block/Broken.php" (26 Nov 2020, 1221 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Broken.php" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 9.0.8_vs_9.1.0-rc1.

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