Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / node / src / Plugin / Action / PublishNode.php
index c8d3b5bfa39474af2f5cb0d4790d2fadb39a3018..2fa8c019ff3be89b693fb9789b4acf4b92958d5b 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;
 
 /**
  * Publishes a node.
@@ -14,24 +14,13 @@ use Drupal\Core\Session\AccountInterface;
  *   type = "node"
  * )
  */
-class PublishNode extends ActionBase {
+class PublishNode extends FieldUpdateActionBase {
 
   /**
    * {@inheritdoc}
    */
-  public function execute($entity = NULL) {
-    $entity->setPublished()->save();
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
-    /** @var \Drupal\node\NodeInterface $object */
-    $result = $object->access('update', $account, TRUE)
-      ->andIf($object->status->access('edit', $account, TRUE));
-
-    return $return_as_object ? $result : $result->isAllowed();
+  protected function getFieldsToUpdate() {
+    return ['status' => NodeInterface::PUBLISHED];
   }
 
 }