comparison core/modules/comment/src/Plugin/Action/UnpublishComment.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\comment\Plugin\Action; 3 namespace Drupal\comment\Plugin\Action;
4 4
5 use Drupal\Core\Action\ActionBase; 5 use Drupal\Core\Action\Plugin\Action\UnpublishAction;
6 use Drupal\Core\Session\AccountInterface; 6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 7
8 /** 8 /**
9 * Unpublishes a comment. 9 * Unpublishes a comment.
10 *
11 * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
12 * Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead.
13 *
14 * @see \Drupal\Core\Action\Plugin\Action\UnpublishAction
15 * @see https://www.drupal.org/node/2919303
10 * 16 *
11 * @Action( 17 * @Action(
12 * id = "comment_unpublish_action", 18 * id = "comment_unpublish_action",
13 * label = @Translation("Unpublish comment"), 19 * label = @Translation("Unpublish comment"),
14 * type = "comment" 20 * type = "comment"
15 * ) 21 * )
16 */ 22 */
17 class UnpublishComment extends ActionBase { 23 class UnpublishComment extends UnpublishAction {
18 24
19 /** 25 /**
20 * {@inheritdoc} 26 * {@inheritdoc}
21 */ 27 */
22 public function execute($comment = NULL) { 28 public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
23 $comment->setPublished(FALSE); 29 parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
24 $comment->save(); 30 @trigger_error(__NAMESPACE__ . '\UnpublishComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
31 /** @var \Drupal\comment\CommentInterface $object */
32 $result = $object->status->access('edit', $account, TRUE)
33 ->andIf($object->access('update', $account, TRUE));
34
35 return $return_as_object ? $result : $result->isAllowed();
36 } 31 }
37 32
38 } 33 }