ViewUIConverter::convert

public ViewUIConverter::convert($value, $definition, $name, array $defaults)

Converts path variables to their corresponding objects.

Parameters

mixed $value: The raw value.

mixed $definition: The parameter definition provided in the route options.

string $name: The name of the parameter.

array $defaults: The route defaults array.

Return value

mixed|null The converted parameter value.

Overrides AdminPathConfigEntityConverter::convert

File

core/modules/views_ui/src/ParamConverter/ViewUIConverter.php, line 66

Class

ViewUIConverter
Provides upcasting for a view entity to be used in the Views UI.

Namespace

Drupal\views_ui\ParamConverter

Code

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);
  }
  // Otherwise, decorate the existing view for use in the UI.
  else {
    $view = new ViewUI($entity);
  }

  return $view;
}
doc_Drupal
2016-10-29 09:56:10
Comments
Leave a Comment

Please login to continue.