ViewRevisionsConverter.php in Config Entity Revisions 8.2
Namespace
Drupal\view_revisions\ParamConverterFile
modules/view_revisions/src/ParamConverter/ViewRevisionsConverter.phpView source
<?php
namespace Drupal\view_revisions\ParamConverter;
use Drupal\config_entity_revisions\ConfigEntityRevisionsConverterBase;
use Symfony\Component\Routing\Route;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\view_revisions\ViewRevisionsUI;
/**
* Provides upcasting for a view entity with revisions support.
*
* Example:
*
* pattern: '/some/{view}/{revision_id}/and/{bar}'
* options:
* parameters:
* view:
* type: 'entity:view'
* tempstore: TRUE
* revision_id:
* \+d
*
* 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}.
*
* This class extends AdminPathConfigEntityConverter rather than ViewUIConverter
* so that ViewUIConverter's converter can be replaced rather than extended
* (we call the parent method). Other methods should remain the same as
* ViewUIConverter.
*/
class ViewRevisionsConverter extends ConfigEntityRevisionsConverterBase implements ParamConverterInterface {
/**
* A prefix for tempstore keys - empty if tempstore is not used.
*/
protected function tempstorePrefix() {
return 'views';
}
/**
* {@inheritdoc}
*/
protected function containerFor($config_entity) {
return new ViewRevisionsUI($config_entity);
}
/**
* Return the config entity name.
*
* @return string
* The config entity name.
*/
protected function configEntityName() {
return 'views';
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
if (parent::applies($definition, $name, $route)) {
return (!empty($definition['tempstore']) || !empty($route
->getRequirement('revision_id'))) && $definition['type'] === 'entity:view';
}
return FALSE;
}
}
Classes
Name | Description |
---|---|
ViewRevisionsConverter | Provides upcasting for a view entity with revisions support. |