CacheClearBlock.php in Akamai 8.3
File
src/Plugin/Block/CacheClearBlock.php
View source
<?php
namespace Drupal\akamai\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Form\FormBuilderInterface;
class CacheClearBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $formBuilder;
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $form_builder;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('form_builder'));
}
public function build() {
$form = $this->formBuilder
->getForm('Drupal\\akamai\\Form\\ClearUrlForm');
return [
'cache_clear_form' => $form,
];
}
public function blockAccess(AccountInterface $account) {
return AccessResult::allowedIfHasPermission($account, 'purge akamai cache');
}
}