Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
4 | 4 |
5 use Drupal\Component\Utility\Html; | 5 use Drupal\Component\Utility\Html; |
6 use Drupal\Component\Utility\Timer; | 6 use Drupal\Component\Utility\Timer; |
7 use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; | 7 use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; |
8 use Drupal\Core\Form\FormStateInterface; | 8 use Drupal\Core\Form\FormStateInterface; |
9 use Drupal\Core\TempStore\Lock; | |
9 use Drupal\views\Views; | 10 use Drupal\views\Views; |
10 use Drupal\Core\Entity\EntityStorageInterface; | 11 use Drupal\Core\Entity\EntityStorageInterface; |
11 use Drupal\views\ViewExecutable; | 12 use Drupal\views\ViewExecutable; |
12 use Drupal\Core\Database\Database; | 13 use Drupal\Core\Database\Database; |
13 use Drupal\Core\Session\AccountInterface; | 14 use Drupal\Core\Session\AccountInterface; |
46 | 47 |
47 /** | 48 /** |
48 * If this view is locked for editing. | 49 * If this view is locked for editing. |
49 * | 50 * |
50 * If this view is locked it will contain the result of | 51 * If this view is locked it will contain the result of |
51 * \Drupal\Core\TempStore\SharedTempStore::getMetadata(). Which can be a stdClass or | 52 * \Drupal\Core\TempStore\SharedTempStore::getMetadata(). |
52 * NULL. | 53 * |
53 * | 54 * For backwards compatibility, public access to this property is provided by |
54 * @var object | 55 * ::__set() and ::__get(). |
55 */ | 56 * |
56 public $lock; | 57 * @var \Drupal\Core\TempStore\Lock|null |
58 */ | |
59 private $lock; | |
57 | 60 |
58 /** | 61 /** |
59 * If this view has been changed. | 62 * If this view has been changed. |
60 * | 63 * |
61 * @var bool | 64 * @var bool |
262 if (!empty($this->changed) && isset($this->form_cache)) { | 265 if (!empty($this->changed) && isset($this->form_cache)) { |
263 unset($this->form_cache); | 266 unset($this->form_cache); |
264 $this->cacheSet(); | 267 $this->cacheSet(); |
265 } | 268 } |
266 | 269 |
267 $form_state->setRedirectUrl($this->urlInfo('edit-form')); | 270 $form_state->setRedirectUrl($this->toUrl('edit-form')); |
268 } | 271 } |
269 | 272 |
270 /** | 273 /** |
271 * Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide | 274 * Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide |
272 * a hidden op operator because the forms plugin doesn't seem to properly | 275 * a hidden op operator because the forms plugin doesn't seem to properly |
886 * | 889 * |
887 * @return bool | 890 * @return bool |
888 * TRUE if the view is locked, FALSE otherwise. | 891 * TRUE if the view is locked, FALSE otherwise. |
889 */ | 892 */ |
890 public function isLocked() { | 893 public function isLocked() { |
891 return is_object($this->lock) && ($this->lock->owner != \Drupal::currentUser()->id()); | 894 $lock = $this->getLock(); |
895 return $lock && $lock->getOwnerId() != \Drupal::currentUser()->id(); | |
892 } | 896 } |
893 | 897 |
894 /** | 898 /** |
895 * Passes through all unknown calls onto the storage object. | 899 * Passes through all unknown calls onto the storage object. |
896 */ | 900 */ |
991 | 995 |
992 /** | 996 /** |
993 * {@inheritdoc} | 997 * {@inheritdoc} |
994 */ | 998 */ |
995 public function urlInfo($rel = 'edit-form', array $options = []) { | 999 public function urlInfo($rel = 'edit-form', array $options = []) { |
996 return $this->storage->urlInfo($rel, $options); | 1000 return $this->storage->toUrl($rel, $options); |
997 } | 1001 } |
998 | 1002 |
999 /** | 1003 /** |
1000 * {@inheritdoc} | 1004 * {@inheritdoc} |
1001 */ | 1005 */ |
1349 */ | 1353 */ |
1350 public function addCacheTags(array $cache_tags) { | 1354 public function addCacheTags(array $cache_tags) { |
1351 return $this->storage->addCacheTags($cache_tags); | 1355 return $this->storage->addCacheTags($cache_tags); |
1352 } | 1356 } |
1353 | 1357 |
1358 /** | |
1359 * Gets the lock on this View. | |
1360 * | |
1361 * @return \Drupal\Core\TempStore\Lock|null | |
1362 * The lock, if one exists. | |
1363 */ | |
1364 public function getLock() { | |
1365 return $this->lock; | |
1366 } | |
1367 | |
1368 /** | |
1369 * Sets a lock on this View. | |
1370 * | |
1371 * @param \Drupal\Core\TempStore\Lock $lock | |
1372 * The lock object. | |
1373 * | |
1374 * @return $this | |
1375 */ | |
1376 public function setLock(Lock $lock) { | |
1377 $this->lock = $lock; | |
1378 return $this; | |
1379 } | |
1380 | |
1381 /** | |
1382 * Unsets the lock on this View. | |
1383 * | |
1384 * @return $this | |
1385 */ | |
1386 public function unsetLock() { | |
1387 $this->lock = NULL; | |
1388 return $this; | |
1389 } | |
1390 | |
1391 /** | |
1392 * {@inheritdoc} | |
1393 */ | |
1394 public function __set($name, $value) { | |
1395 if ($name === 'lock') { | |
1396 @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); | |
1397 if ($value instanceof \stdClass && property_exists($value, 'owner') && property_exists($value, 'updated')) { | |
1398 $value = new Lock($value->owner, $value->updated); | |
1399 } | |
1400 $this->setLock($value); | |
1401 } | |
1402 else { | |
1403 $this->{$name} = $value; | |
1404 } | |
1405 } | |
1406 | |
1407 /** | |
1408 * {@inheritdoc} | |
1409 */ | |
1410 public function __get($name) { | |
1411 if ($name === 'lock') { | |
1412 @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); | |
1413 return $this->getLock(); | |
1414 } | |
1415 } | |
1416 | |
1354 } | 1417 } |