Mercurial > hg > isophonics-drupal-site
diff core/modules/quickedit/quickedit.module @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 7a779792577d |
children | af1871eacc83 |
line wrap: on
line diff
--- a/core/modules/quickedit/quickedit.module Mon Apr 23 09:33:26 2018 +0100 +++ b/core/modules/quickedit/quickedit.module Mon Apr 23 09:46:53 2018 +0100 @@ -130,10 +130,10 @@ function quickedit_preprocess_field(&$variables) { $variables['#cache']['contexts'][] = 'user.permissions'; $element = $variables['element']; - /** @var $entity \Drupal\Core\Entity\EntityInterface */ + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $element['#object']; - if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) { + if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !$entity->isLatestRevision()) { return; } @@ -157,8 +157,9 @@ * Implements hook_entity_view_alter(). */ function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) { + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $build['#cache']['contexts'][] = 'user.permissions'; - if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) { + if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !$entity->isLatestRevision()) { return; } @@ -174,22 +175,14 @@ * @return bool * TRUE if the loaded entity is the latest revision, FALSE otherwise. * - * @todo Remove this method once better support for pending revisions is added - * to core https://www.drupal.org/node/2784201. + * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use + * \Drupal\Core\Entity\RevisionableInterface::isLatestRevision() instead. + * As internal API, _quickedit_entity_is_latest_revision() may also be removed + * in a minor release. * * @internal */ function _quickedit_entity_is_latest_revision(ContentEntityInterface $entity) { - if (!$entity->getEntityType()->isRevisionable() || $entity->isNew()) { - return TRUE; - } - - $latest_revision = \Drupal::entityTypeManager() - ->getStorage($entity->getEntityTypeId()) - ->getQuery() - ->latestRevision() - ->condition($entity->getEntityType()->getKey('id'), $entity->id()) - ->execute(); - - return !empty($latest_revision) && $entity->getLoadedRevisionId() == key($latest_revision) ? TRUE : FALSE; + @trigger_error('_quickedit_entity_is_latest_revision() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\RevisionableInterface::isLatestRevision() instead. As internal API, _quickedit_entity_is_latest_revision() may also be removed in a minor release.', E_USER_DEPRECATED); + return $entity->isLatestRevision(); }