SearchBlock.php 814 Bytes
Newer Older
1
2
3
4
<?php

/**
 * @file
5
 * Contains \Drupal\search\Plugin\Block\SearchBlock.
6
7
 */

8
namespace Drupal\search\Plugin\Block;
9

10
use Drupal\Core\Session\AccountInterface;
11
use Drupal\block\BlockBase;
12
13
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
14
15
16
17

/**
 * Provides a 'Search form' block.
 *
18
 * @Block(
19
 *   id = "search_form_block",
20
21
 *   admin_label = @Translation("Search form"),
 *   category = @Translation("Forms")
22
23
 * )
 */
24
class SearchBlock extends BlockBase {
25
26

  /**
27
   * {@inheritdoc}
28
   */
29
  protected function blockAccess(AccountInterface $account) {
30
    return $account->hasPermission('search content');
31
32
33
  }

  /**
34
   * {@inheritdoc}
35
   */
36
  public function build() {
37
    return \Drupal::formBuilder()->getForm('Drupal\search\Form\SearchBlockForm');
38
  }
39

40
}