class FeatureListMenuLink in Configuration selector 8
Same name and namespace in other branches
- 8.2 src/Plugin/Derivative/FeatureListMenuLink.php \Drupal\config_selector\Plugin\Derivative\FeatureListMenuLink
Test derivative with an unsafe string.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\config_selector\Plugin\Derivative\FeatureListMenuLink implements ContainerInjectionInterface, ContainerDeriverInterface
Expanded class hierarchy of FeatureListMenuLink
1 string reference to 'FeatureListMenuLink'
File
- src/
Plugin/ Derivative/ FeatureListMenuLink.php, line 15
Namespace
Drupal\config_selector\Plugin\DerivativeView source
class FeatureListMenuLink extends DeriverBase implements ContainerDeriverInterface, ContainerInjectionInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* FeatureListAccessCheck constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id = '') {
return new static($container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if ($this
->count()) {
$this->derivatives['config_selector.admin_display'] = $base_plugin_definition;
}
return $this->derivatives;
}
/**
* Allows access to Config Selector UI if there are entities.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access() {
$entity_type = $this->entityTypeManager
->getDefinition('config_selector_feature');
return AccessResult::allowedIf($this
->count() > 0)
->addCacheTags($entity_type
->getListCacheTags())
->addCacheContexts($entity_type
->getListCacheContexts());
}
/**
* Gets the count of feature entities.
*
* @return int
* The count of feature entities.
*/
protected function count() {
return $this->entityTypeManager
->getStorage('config_selector_feature')
->getQuery()
->accessCheck(TRUE)
->count()
->execute();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
FeatureListMenuLink:: |
protected | property | The entity type manager. | |
FeatureListMenuLink:: |
public | function | Allows access to Config Selector UI if there are entities. | |
FeatureListMenuLink:: |
protected | function | Gets the count of feature entities. | |
FeatureListMenuLink:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
FeatureListMenuLink:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
FeatureListMenuLink:: |
public | function | FeatureListAccessCheck constructor. |