class ContextMapper in Page Manager 8.4
Same name and namespace in other branches
- 8 src/ContextMapper.php \Drupal\page_manager\ContextMapper
Maps context configurations to context objects.
Hierarchy
- class \Drupal\page_manager\ContextMapper implements ContextMapperInterface
Expanded class hierarchy of ContextMapper
1 file declares its use of ContextMapper
- ContextMapperTest.php in tests/
src/ Unit/ ContextMapperTest.php
1 string reference to 'ContextMapper'
1 service uses ContextMapper
File
- src/
ContextMapper.php, line 13
Namespace
Drupal\page_managerView source
class ContextMapper implements ContextMapperInterface {
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* Constructs a new ContextMapper.
*
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
*/
public function __construct(EntityRepositoryInterface $entity_repository) {
$this->entityRepository = $entity_repository;
}
/**
* {@inheritdoc}
*/
public function getContextValues(array $context_configurations) {
$contexts = [];
foreach ($context_configurations as $name => $context_configuration) {
$context_definition = ContextDefinitionFactory::create($context_configuration['type'])
->setLabel($context_configuration['label']);
if (strpos($context_configuration['type'], 'entity:') === 0) {
$context = new EntityLazyLoadContext($context_definition, $this->entityRepository, $context_configuration['value']);
}
else {
$context = new Context($context_definition, $context_configuration['value']);
}
$contexts[$name] = $context;
}
return $contexts;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextMapper:: |
protected | property | The entity repository. | |
ContextMapper:: |
public | function |
Gathers the static context values. Overrides ContextMapperInterface:: |
|
ContextMapper:: |
public | function | Constructs a new ContextMapper. |