class GroupInfo in Block Visibility Groups 8
Class GroupInfo.
@package Drupal\block_visibility_groups_admin
Hierarchy
- class \Drupal\block_visibility_groups_admin\GroupInfo implements GroupInfoInterface
Expanded class hierarchy of GroupInfo
1 string reference to 'GroupInfo'
- block_visibility_groups_admin.services.yml in block_visibility_groups_admin/
block_visibility_groups_admin.services.yml - block_visibility_groups_admin/block_visibility_groups_admin.services.yml
1 service uses GroupInfo
- block_visibility_groups_admin.lister in block_visibility_groups_admin/
block_visibility_groups_admin.services.yml - Drupal\block_visibility_groups_admin\GroupInfo
File
- block_visibility_groups_admin/
src/ GroupInfo.php, line 14
Namespace
Drupal\block_visibility_groups_adminView source
class GroupInfo implements GroupInfoInterface {
/**
* Drupal\block_visibility_groups\GroupEvaluator definition.
*
* @var \Drupal\block_visibility_groups\GroupEvaluator
*/
protected $block_visibility_groups_group_evaluator;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $group_storage;
/**
* @var \Drupal\Core\Executable\ExecutableManagerInterface
*/
protected $condition_manager;
/**
* Constructor.
*
* @param \Drupal\block_visibility_groups\GroupEvaluator $block_visibility_groups_group_evaluator
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* @param \Drupal\Core\Executable\ExecutableManagerInterface $condition_manager
*/
public function __construct(GroupEvaluator $block_visibility_groups_group_evaluator, EntityTypeManagerInterface $entity_manager, ExecutableManagerInterface $condition_manager) {
$this->block_visibility_groups_group_evaluator = $block_visibility_groups_group_evaluator;
$this->group_storage = $entity_manager
->getStorage('block_visibility_group');
$this->condition_manager = $condition_manager;
}
/**
* Get all active groups.
*
* @return \Drupal\block_visibility_groups\Entity\BlockVisibilityGroup[]
*/
public function getActiveGroups() {
$active_groups = [];
/** @var BlockVisibilityGroup $group */
foreach ($this->group_storage
->loadMultiple() as $id => $group) {
/** @var \Drupal\block_visibility_groups\Plugin\Condition\ConditionGroup $condition ; */
$condition = $this->condition_manager
->createInstance('condition_group', [
'block_visibility_group' => $id,
]);
if ($condition
->evaluate()) {
$active_groups[$id] = $group;
}
}
return $active_groups;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GroupInfo:: |
protected | property | Drupal\block_visibility_groups\GroupEvaluator definition. | |
GroupInfo:: |
protected | property | ||
GroupInfo:: |
protected | property | ||
GroupInfo:: |
public | function | Get all active groups. | |
GroupInfo:: |
public | function | Constructor. |