class ViewUIConverter in Zircon Profile 8
Same name in this branch
- 8 core/modules/views_ui/src/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ParamConverter\ViewUIConverter
- 8 core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter
Same name and namespace in other branches
- 8.0 core/modules/views_ui/src/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ParamConverter\ViewUIConverter
Provides upcasting for a view entity to be used in the Views UI.
Example:
pattern: '/some/{view}/and/{bar}' options: parameters: view: type: 'entity:view' tempstore: TRUE
The value for {view} will be converted to a view entity prepared for the Views UI and loaded from the views temp store, but it will not touch the value for {bar}.
Hierarchy
- class \Drupal\Core\ParamConverter\EntityConverter implements ParamConverterInterface
- class \Drupal\views_ui\ParamConverter\ViewUIConverter implements ParamConverterInterface
Expanded class hierarchy of ViewUIConverter
1 string reference to 'ViewUIConverter'
- views_ui.services.yml in core/
modules/ views_ui/ views_ui.services.yml - core/modules/views_ui/views_ui.services.yml
1 service uses ViewUIConverter
- paramconverter.views_ui in core/
modules/ views_ui/ views_ui.services.yml - Drupal\views_ui\ParamConverter\ViewUIConverter
File
- core/
modules/ views_ui/ src/ ParamConverter/ ViewUIConverter.php, line 33 - Contains \Drupal\views_ui\ParamConverter\ViewUIConverter.
Namespace
Drupal\views_ui\ParamConverterView source
class ViewUIConverter extends EntityConverter implements ParamConverterInterface {
/**
* Stores the tempstore factory.
*
* @var \Drupal\user\SharedTempStoreFactory
*/
protected $tempStoreFactory;
/**
* Constructs a new ViewUIConverter.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\user\SharedTempStoreFactory $temp_store_factory
* The factory for the temp store object.
*/
public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory) {
parent::__construct($entity_manager);
$this->tempStoreFactory = $temp_store_factory;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
if (!($entity = parent::convert($value, $definition, $name, $defaults))) {
return;
}
// Get the temp store for this variable if it needs one. Attempt to load the
// view from the temp store, synchronize its status with the existing view,
// and store the lock metadata.
$store = $this->tempStoreFactory
->get('views');
if ($view = $store
->get($value)) {
if ($entity
->status()) {
$view
->enable();
}
else {
$view
->disable();
}
$view->lock = $store
->getMetadata($value);
}
else {
$view = new ViewUI($entity);
}
return $view;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
if (parent::applies($definition, $name, $route)) {
return !empty($definition['tempstore']) && $definition['type'] === 'entity:view';
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityConverter:: |
protected | property | Entity manager which performs the upcasting in the end. | |
EntityConverter:: |
protected | function | Determines the entity type ID given a route definition and route defaults. | |
ViewUIConverter:: |
protected | property | Stores the tempstore factory. | |
ViewUIConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides EntityConverter:: |
|
ViewUIConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides EntityConverter:: |
|
ViewUIConverter:: |
public | function |
Constructs a new ViewUIConverter. Overrides EntityConverter:: |