You are here

public function SearchStyleguide::items in Style Guide 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Styleguide/SearchStyleguide.php \Drupal\styleguide\Plugin\Styleguide\SearchStyleguide::items()

Styleguide elements implementation.

Return value

array An array of Styleguide elements.

Overrides StyleguideInterface::items

File

src/Plugin/Styleguide/SearchStyleguide.php, line 135

Class

SearchStyleguide
Search Styleguide items implementation.

Namespace

Drupal\styleguide\Plugin\Styleguide

Code

public function items() {
  $items = [];
  if ($this->moduleHandler
    ->moduleExists('search')) {
    $items['search_block_form'] = [
      'title' => $this
        ->t('Search block form'),
      'content' => $this->formBuilder
        ->getForm('Drupal\\search\\Form\\SearchBlockForm'),
      'group' => $this
        ->t('Search'),
    ];
    $items['search_no_results'] = [
      'title' => $this
        ->t('Search, no results'),
      'content' => [
        '#theme' => 'item_list__search_results',
        '#items' => [],
        '#empty' => [
          '#markup' => '<h3>' . $this
            ->t('Your search yielded no results.') . '</h3>',
        ],
      ],
      'group' => $this
        ->t('Search'),
    ];

    // Generate sample results.
    $this
      ->searchResults($items);
  }
  return $items;
}