You are here

SearchBlock.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/search/src/Plugin/Block/SearchBlock.php

File

core/modules/search/src/Plugin/Block/SearchBlock.php
View source
<?php

/**
 * @file
 * Contains \Drupal\search\Plugin\Block\SearchBlock.
 */
namespace Drupal\search\Plugin\Block;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Search form' block.
 *
 * @Block(
 *   id = "search_form_block",
 *   admin_label = @Translation("Search form"),
 *   category = @Translation("Forms")
 * )
 */
class SearchBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  protected function blockAccess(AccountInterface $account) {
    return AccessResult::allowedIfHasPermission($account, 'search content');
  }

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

}

Classes

Namesort descending Description
SearchBlock Provides a 'Search form' block.