Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / node / src / Plugin / Action / UnstickyNode.php
index 92ccfe2c0975c546db11c232dfe5678b6261c438..c074fe9e5a3df8e59abc67d232da3073d3b39e35 100644 (file)
@@ -2,8 +2,8 @@
 
 namespace Drupal\node\Plugin\Action;
 
-use Drupal\Core\Action\ActionBase;
-use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Field\FieldUpdateActionBase;
+use Drupal\node\NodeInterface;
 
 /**
  * Makes a node not sticky.
@@ -14,24 +14,13 @@ use Drupal\Core\Session\AccountInterface;
  *   type = "node"
  * )
  */
-class UnstickyNode extends ActionBase {
+class UnstickyNode extends FieldUpdateActionBase {
 
   /**
    * {@inheritdoc}
    */
-  public function execute($entity = NULL) {
-    $entity->setSticky(FALSE)->save();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
-    /** @var \Drupal\node\NodeInterface $object */
-    $access = $object->access('update', $account, TRUE)
-      ->andIf($object->sticky->access('edit', $account, TRUE));
-
-    return $return_as_object ? $access : $access->isAllowed();
+  protected function getFieldsToUpdate() {
+    return ['sticky' => NodeInterface::NOT_STICKY];
   }
 
 }