Mercurial > hg > cmmr2012-drupal-site
diff core/modules/views_ui/src/ViewUI.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
line wrap: on
line diff
--- a/core/modules/views_ui/src/ViewUI.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/views_ui/src/ViewUI.php Thu May 09 15:34:47 2019 +0100 @@ -6,6 +6,7 @@ use Drupal\Component\Utility\Timer; use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\TempStore\Lock; use Drupal\views\Views; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\views\ViewExecutable; @@ -48,12 +49,14 @@ * If this view is locked for editing. * * If this view is locked it will contain the result of - * \Drupal\Core\TempStore\SharedTempStore::getMetadata(). Which can be a stdClass or - * NULL. + * \Drupal\Core\TempStore\SharedTempStore::getMetadata(). * - * @var object + * For backwards compatibility, public access to this property is provided by + * ::__set() and ::__get(). + * + * @var \Drupal\Core\TempStore\Lock|null */ - public $lock; + private $lock; /** * If this view has been changed. @@ -264,7 +267,7 @@ $this->cacheSet(); } - $form_state->setRedirectUrl($this->urlInfo('edit-form')); + $form_state->setRedirectUrl($this->toUrl('edit-form')); } /** @@ -888,7 +891,8 @@ * TRUE if the view is locked, FALSE otherwise. */ public function isLocked() { - return is_object($this->lock) && ($this->lock->owner != \Drupal::currentUser()->id()); + $lock = $this->getLock(); + return $lock && $lock->getOwnerId() != \Drupal::currentUser()->id(); } /** @@ -993,7 +997,7 @@ * {@inheritdoc} */ public function urlInfo($rel = 'edit-form', array $options = []) { - return $this->storage->urlInfo($rel, $options); + return $this->storage->toUrl($rel, $options); } /** @@ -1351,4 +1355,63 @@ return $this->storage->addCacheTags($cache_tags); } + /** + * Gets the lock on this View. + * + * @return \Drupal\Core\TempStore\Lock|null + * The lock, if one exists. + */ + public function getLock() { + return $this->lock; + } + + /** + * Sets a lock on this View. + * + * @param \Drupal\Core\TempStore\Lock $lock + * The lock object. + * + * @return $this + */ + public function setLock(Lock $lock) { + $this->lock = $lock; + return $this; + } + + /** + * Unsets the lock on this View. + * + * @return $this + */ + public function unsetLock() { + $this->lock = NULL; + return $this; + } + + /** + * {@inheritdoc} + */ + public function __set($name, $value) { + if ($name === 'lock') { + @trigger_error('Using the "lock" public property of a View is deprecated in Drupal 8.7.0 and will not be allowed in Drupal 9.0.0. Use \Drupal\views_ui\ViewUI::setLock() instead. See https://www.drupal.org/node/3025869.', E_USER_DEPRECATED); + if ($value instanceof \stdClass && property_exists($value, 'owner') && property_exists($value, 'updated')) { + $value = new Lock($value->owner, $value->updated); + } + $this->setLock($value); + } + else { + $this->{$name} = $value; + } + } + + /** + * {@inheritdoc} + */ + public function __get($name) { + if ($name === 'lock') { + @trigger_error('Using the "lock" public property of a View is deprecated in Drupal 8.7.0 and will not be allowed in Drupal 9.0.0. Use \Drupal\views_ui\ViewUI::getLock() instead. See https://www.drupal.org/node/3025869.', E_USER_DEPRECATED); + return $this->getLock(); + } + } + }