Mercurial > hg > isophonics-drupal-site
comparison core/modules/comment/src/Plugin/Action/PublishComment.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\comment\Plugin\Action; | |
4 | |
5 use Drupal\Core\Action\ActionBase; | |
6 use Drupal\Core\Session\AccountInterface; | |
7 | |
8 /** | |
9 * Publishes a comment. | |
10 * | |
11 * @Action( | |
12 * id = "comment_publish_action", | |
13 * label = @Translation("Publish comment"), | |
14 * type = "comment" | |
15 * ) | |
16 */ | |
17 class PublishComment extends ActionBase { | |
18 | |
19 /** | |
20 * {@inheritdoc} | |
21 */ | |
22 public function execute($comment = NULL) { | |
23 $comment->setPublished(TRUE); | |
24 $comment->save(); | |
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 } | |
37 | |
38 } |