class AutowireBlock

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/autowire_test/src/Plugin/Block/AutowireBlock.php \Drupal\autowire_test\Plugin\Block\AutowireBlock

Provides a block that can be autowired.

Attributes

#[Block(id: "autowire", admin_label: new TranslatableMarkup("Autowire block"))]

Hierarchy

Expanded class hierarchy of AutowireBlock

1 file declares its use of AutowireBlock
AutowireBlockTest.php in core/tests/Drupal/KernelTests/Core/Block/AutowireBlockTest.php

File

core/modules/system/tests/modules/autowire_test/src/Plugin/Block/AutowireBlock.php, line 17

Namespace

Drupal\autowire_test\Plugin\Block
View source
class AutowireBlock extends BlockBase implements ContainerFactoryPluginInterface {
  
  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, #[Autowire(service: 'lock')] protected LockBackendInterface $lock) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }
  
  /**
   * {@inheritdoc}
   */
  public function build() {
    return [];
  }
  
  /**
   * Gets the lock service.
   */
  public function getLock() : LockBackendInterface {
    return $this->lock;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.