You are here

class ViewRevisionsConverter in Config Entity Revisions 8.2

Same name in this branch
  1. 8.2 modules/view_revisions/src/ParamConverter/ViewRevisionsConverter.php \Drupal\view_revisions\ParamConverter\ViewRevisionsConverter
  2. 8.2 modules/view_revisions/src/ProxyClass/ParamConverter/ViewRevisionsConverter.php \Drupal\view_revisions\ProxyClass\ParamConverter\ViewRevisionsConverter

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.

Hierarchy

Expanded class hierarchy of ViewRevisionsConverter

1 string reference to 'ViewRevisionsConverter'
view_revisions.services.yml in modules/view_revisions/view_revisions.services.yml
modules/view_revisions/view_revisions.services.yml
1 service uses ViewRevisionsConverter
paramconverter.view_revision in modules/view_revisions/view_revisions.services.yml
Drupal\view_revisions\ParamConverter\ViewRevisionsConverter

File

modules/view_revisions/src/ParamConverter/ViewRevisionsConverter.php, line 33

Namespace

Drupal\view_revisions\ParamConverter
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminPathConfigEntityConverter::$adminContext protected property The route admin context to determine whether a route is an admin one.
AdminPathConfigEntityConverter::$configFactory protected property The config factory.
ConfigEntityRevisionsConverterBase::$tempStoreFactory protected property Stores the tempstore factory.
ConfigEntityRevisionsConverterBase::convert public function Converts path variables to their corresponding objects. Overrides AdminPathConfigEntityConverter::convert
ConfigEntityRevisionsConverterBase::getEntityTypeFromDefaults public function Determines the entity type ID given a route definition and route defaults. Overrides DynamicEntityTypeParamConverterTrait::getEntityTypeFromDefaults
ConfigEntityRevisionsConverterBase::__construct public function Constructs a new converter. Overrides AdminPathConfigEntityConverter::__construct
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
EntityConverter::$deprecatedProperties protected property
EntityConverter::$entityRepository protected property Entity repository.
EntityConverter::$entityTypeManager protected property Entity type manager which performs the upcasting in the end.
EntityConverter::getLatestTranslationAffectedRevision Deprecated protected function Returns the latest revision translation of the specified entity.
EntityConverter::languageManager protected function Returns a language manager instance.
EntityConverter::loadRevision Deprecated protected function Loads the specified entity revision.
ViewRevisionsConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides AdminPathConfigEntityConverter::applies
ViewRevisionsConverter::configEntityName protected function Return the config entity name.
ViewRevisionsConverter::containerFor protected function Default implementation of containerFor - the container is the object. Overrides ConfigEntityRevisionsConverterBase::containerFor
ViewRevisionsConverter::tempstorePrefix protected function A prefix for tempstore keys - empty if tempstore is not used. Overrides ConfigEntityRevisionsConverterBase::tempstorePrefix