class ContextDefinitionFactory in Page Manager 8.4
Provides a simple factory for context definitions.
Hierarchy
- class \Drupal\page_manager\Context\ContextDefinitionFactory
Expanded class hierarchy of ContextDefinitionFactory
4 files declare their use of ContextDefinitionFactory
- ContextMapper.php in src/
ContextMapper.php - ContextMapperTest.php in tests/
src/ Unit/ ContextMapperTest.php - Page.php in src/
Entity/ Page.php - RouteParamContext.php in src/
EventSubscriber/ RouteParamContext.php
File
- src/
Context/ ContextDefinitionFactory.php, line 10
Namespace
Drupal\page_manager\ContextView source
class ContextDefinitionFactory {
/**
* Creates a context definition.
*
* @param string $data_type
* The context's data type, as known to the core Typed Data system.
*
* @return \Drupal\Core\Plugin\Context\ContextDefinition
* The context definition.
*/
public static function create($data_type) {
// @todo: Remove this class_exists() check once Drupal 8.6 is the earliest
// supported version of core.
$class = '\\Drupal\\Core\\Plugin\\Context\\EntityContextDefinition';
if (strpos($data_type, 'entity:') === 0 && class_exists($class)) {
return $class::create($data_type);
}
return ContextDefinition::create($data_type);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextDefinitionFactory:: |
public static | function | Creates a context definition. |