You are here

class PageTitleBlock in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php \Drupal\Core\Block\Plugin\Block\PageTitleBlock
  2. 9 core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php \Drupal\Core\Block\Plugin\Block\PageTitleBlock

Provides a block to display the page title.

Plugin annotation


@Block(
  id = "page_title_block",
  admin_label = @Translation("Page title"),
  forms = {
    "settings_tray" = FALSE,
  },
)

Hierarchy

  • class \Drupal\Core\Block\Plugin\Block\PageTitleBlock extends \Drupal\Core\Block\BlockBase implements \Drupal\Core\Block\TitleBlockPluginInterface

Expanded class hierarchy of PageTitleBlock

File

core/lib/Drupal/Core/Block/Plugin/Block/PageTitleBlock.php, line 19

Namespace

Drupal\Core\Block\Plugin\Block
View source
class PageTitleBlock extends BlockBase implements TitleBlockPluginInterface {

  /**
   * The page title: a string (plain title) or a render array (formatted title).
   *
   * @var string|array
   */
  protected $title = '';

  /**
   * {@inheritdoc}
   */
  public function setTitle($title) {
    $this->title = $title;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'label_display' => FALSE,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#type' => 'page_title',
      '#title' => $this->title,
    ];
  }

}

Members