class Broken in Drupal 10
Same name in this branch
- 10 core/lib/Drupal/Core/Block/Plugin/Block/Broken.php \Drupal\Core\Block\Plugin\Block\Broken
- 10 core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php \Drupal\Core\Entity\Plugin\EntityReferenceSelection\Broken
- 10 core/modules/views/src/Plugin/views/area/Broken.php \Drupal\views\Plugin\views\area\Broken
- 10 core/modules/views/src/Plugin/views/relationship/Broken.php \Drupal\views\Plugin\views\relationship\Broken
- 10 core/modules/views/src/Plugin/views/filter/Broken.php \Drupal\views\Plugin\views\filter\Broken
- 10 core/modules/views/src/Plugin/views/sort/Broken.php \Drupal\views\Plugin\views\sort\Broken
- 10 core/modules/views/src/Plugin/views/argument/Broken.php \Drupal\views\Plugin\views\argument\Broken
- 10 core/modules/views/src/Plugin/views/field/Broken.php \Drupal\views\Plugin\views\field\Broken
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Block/Plugin/Block/Broken.php \Drupal\Core\Block\Plugin\Block\Broken
- 9 core/lib/Drupal/Core/Block/Plugin/Block/Broken.php \Drupal\Core\Block\Plugin\Block\Broken
Defines a fallback plugin for missing block plugins.
Plugin annotation
@Block(
id = "broken",
admin_label = @Translation("Broken/Missing"),
category = @Translation("Block"),
)
Hierarchy
- class \Drupal\Core\Block\Plugin\Block\Broken extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Block\BlockPluginInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface uses \Drupal\Core\Block\BlockPluginTrait, \Drupal\Core\Cache\CacheableDependencyTrait
Expanded class hierarchy of Broken
1 file declares its use of Broken
- BlockManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Block/ BlockManagerTest.php
6 string references to 'Broken'
- View::addDisplay in core/
modules/ views/ src/ Entity/ View.php - Adds a new display handler to the view, automatically creating an ID.
- views.argument.schema.yml in core/
modules/ views/ config/ schema/ views.argument.schema.yml - core/modules/views/config/schema/views.argument.schema.yml
- views.field.schema.yml in core/
modules/ views/ config/ schema/ views.field.schema.yml - core/modules/views/config/schema/views.field.schema.yml
- views.filter.schema.yml in core/
modules/ views/ config/ schema/ views.filter.schema.yml - core/modules/views/config/schema/views.filter.schema.yml
- views.relationship.schema.yml in core/
modules/ views/ config/ schema/ views.relationship.schema.yml - core/modules/views/config/schema/views.relationship.schema.yml
File
- core/
lib/ Drupal/ Core/ Block/ Plugin/ Block/ Broken.php, line 23
Namespace
Drupal\Core\Block\Plugin\BlockView source
class Broken extends PluginBase implements BlockPluginInterface, ContainerFactoryPluginInterface {
use BlockPluginTrait;
use CacheableDependencyTrait;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* Creates a Broken Block instance.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->currentUser = $current_user;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('current_user'));
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
if ($this->currentUser
->hasPermission('administer blocks')) {
$build += $this
->brokenMessage();
}
return $build;
}
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
return $this
->brokenMessage();
}
/**
* Generate message with debugging information as to why the block is broken.
*
* @return array
* Render array containing debug information.
*/
protected function brokenMessage() {
$build['message'] = [
'#markup' => $this
->t('This block is broken or missing. You may be missing content or you might need to enable the original module.'),
];
return $build;
}
}