l10n_server-2.x-dev/l10n_community/src/Plugin/Block/PickGoFormBlock.php
l10n_community/src/Plugin/Block/PickGoFormBlock.php
<?php declare(strict_types=1); namespace Drupal\l10n_community\Plugin\Block; use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; use Drupal\Core\Cache\Cache; use Drupal\Core\Session\AccountInterface; /** * Provides a jump form block. * * @Block( * id = "l10n_community_pick_go_form", * admin_label = @Translation("Pick and go form"), * category = @Translation("L10n") * ) */ class PickGoFormBlock extends BlockBase { /** * {@inheritdoc} */ public function build() { return \Drupal::formBuilder()->getForm('\Drupal\l10n_community\Form\PickGoForm'); } /** * {@inheritdoc} */ protected function blockAccess(AccountInterface $account) { return AccessResult::allowedIf( $account->hasPermission('access localization community') ); } /** * {@inheritdoc} */ public function getCacheContexts() { return Cache::mergeContexts( parent::getCacheContexts(), ['url.path'] ); } }