DsTestBlock.php in Display Suite 8.4
Same filename and directory in other branches
Namespace
Drupal\ds_test\Plugin\BlockFile
tests/modules/ds_test/src/Plugin/Block/DsTestBlock.phpView source
<?php
namespace Drupal\ds_test\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Block\BlockBase;
/**
* Defines a Display suite test block.
*
* @Block(
* id = "ds_test_block",
* admin_label = @Translation("Display Suite Test Block"),
* category = @Translation("ds")
* )
*/
class DsTestBlock extends BlockBase {
const BODY_TEXT = 'Display suite test block.';
/**
* {@inheritdoc}
*/
protected function blockAccess(AccountInterface $account) {
return AccessResult::allowedIf(\Drupal::state()
->get('ds_test_block__access', FALSE));
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$build[]['#markup'] = $this::BODY_TEXT;
return $build;
}
/**
* Ensure that this object is not cached.
*/
public function getCacheMaxAge() {
return 0;
}
}
Classes
Name | Description |
---|---|
DsTestBlock | Defines a Display suite test block. |