comparison core/modules/node/src/Plugin/Action/SaveNode.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php 1 <?php
2 2
3 namespace Drupal\node\Plugin\Action; 3 namespace Drupal\node\Plugin\Action;
4 4
5 use Drupal\Core\Action\ActionBase; 5 use Drupal\Component\Datetime\TimeInterface;
6 use Drupal\Core\Session\AccountInterface; 6 use Drupal\Core\Action\Plugin\Action\SaveAction;
7 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 8
8 /** 9 /**
9 * Provides an action that can save any entity. 10 * Provides an action that can save any entity.
11 *
12 * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
13 * Use \Drupal\Core\Action\Plugin\Action\SaveAction instead.
14 *
15 * @see \Drupal\Core\Action\Plugin\Action\SaveAction
16 * @see https://www.drupal.org/node/2919303
10 * 17 *
11 * @Action( 18 * @Action(
12 * id = "node_save_action", 19 * id = "node_save_action",
13 * label = @Translation("Save content"), 20 * label = @Translation("Save content"),
14 * type = "node" 21 * type = "node"
15 * ) 22 * )
16 */ 23 */
17 class SaveNode extends ActionBase { 24 class SaveNode extends SaveAction {
18 25
19 /** 26 /**
20 * {@inheritdoc} 27 * {@inheritdoc}
21 */ 28 */
22 public function execute($entity = NULL) { 29 public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, TimeInterface $time) {
23 // We need to change at least one value, otherwise the changed timestamp 30 parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $time);
24 // will not be updated. 31 @trigger_error(__NAMESPACE__ . '\SaveNode is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\SaveAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
25 $entity->changed = 0;
26 $entity->save();
27 }
28
29 /**
30 * {@inheritdoc}
31 */
32 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
33 /** @var \Drupal\node\NodeInterface $object */
34 return $object->access('update', $account, $return_as_object);
35 } 32 }
36 33
37 } 34 }