Chris@0: tempStoreFactory = $temp_store_factory; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function convert($value, $definition, $name, array $defaults) { Chris@0: if (!$entity = parent::convert($value, $definition, $name, $defaults)) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Get the temp store for this variable if it needs one. Attempt to load the Chris@0: // view from the temp store, synchronize its status with the existing view, Chris@0: // and store the lock metadata. Chris@0: $store = $this->tempStoreFactory->get('views'); Chris@0: if ($view = $store->get($value)) { Chris@0: if ($entity->status()) { Chris@0: $view->enable(); Chris@0: } Chris@0: else { Chris@0: $view->disable(); Chris@0: } Chris@18: $view->setLock($store->getMetadata($value)); Chris@0: } Chris@0: // Otherwise, decorate the existing view for use in the UI. Chris@0: else { Chris@0: $view = new ViewUI($entity); Chris@0: } Chris@0: Chris@0: return $view; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function applies($definition, $name, Route $route) { Chris@0: if (parent::applies($definition, $name, $route)) { Chris@0: return !empty($definition['tempstore']) && $definition['type'] === 'entity:view'; Chris@0: } Chris@0: return FALSE; Chris@0: } Chris@0: Chris@0: }