function ViewUIConverter::convert

Same name in this branch
  1. 9 core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter::convert()
Same name in other branches
  1. 8.9.x core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter::convert()
  2. 8.9.x core/modules/views_ui/src/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ParamConverter\ViewUIConverter::convert()
  3. 10 core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter::convert()
  4. 10 core/modules/views_ui/src/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ParamConverter\ViewUIConverter::convert()
  5. 11.x core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter::convert()
  6. 11.x core/modules/views_ui/src/ParamConverter/ViewUIConverter.php \Drupal\views_ui\ParamConverter\ViewUIConverter::convert()

Overrides AdminPathConfigEntityConverter::convert

File

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

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->setLock($store->getMetadata($value));
    }
    else {
        $view = new ViewUI($entity);
    }
    return $view;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.