annotate core/modules/node/src/Plugin/Action/SaveNode.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\node\Plugin\Action;
Chris@0 4
Chris@0 5 use Drupal\Core\Action\ActionBase;
Chris@0 6 use Drupal\Core\Session\AccountInterface;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Provides an action that can save any entity.
Chris@0 10 *
Chris@0 11 * @Action(
Chris@0 12 * id = "node_save_action",
Chris@0 13 * label = @Translation("Save content"),
Chris@0 14 * type = "node"
Chris@0 15 * )
Chris@0 16 */
Chris@0 17 class SaveNode extends ActionBase {
Chris@0 18
Chris@0 19 /**
Chris@0 20 * {@inheritdoc}
Chris@0 21 */
Chris@0 22 public function execute($entity = NULL) {
Chris@0 23 // We need to change at least one value, otherwise the changed timestamp
Chris@0 24 // will not be updated.
Chris@0 25 $entity->changed = 0;
Chris@0 26 $entity->save();
Chris@0 27 }
Chris@0 28
Chris@0 29 /**
Chris@0 30 * {@inheritdoc}
Chris@0 31 */
Chris@0 32 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
Chris@0 33 /** @var \Drupal\node\NodeInterface $object */
Chris@0 34 return $object->access('update', $account, $return_as_object);
Chris@0 35 }
Chris@0 36
Chris@0 37 }