l10n_server-2.x-dev/l10n_community/src/Plugin/Block/JumpFormBlock.php
l10n_community/src/Plugin/Block/JumpFormBlock.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_jump_form", * admin_label = @Translation("Jump form"), * category = @Translation("L10n") * ) */ class JumpFormBlock extends BlockBase { /** * {@inheritdoc} */ public function build() { return \Drupal::formBuilder()->getForm('\Drupal\l10n_community\Form\JumpForm'); } /** * {@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'] ); } }