Mercurial > hg > isophonics-drupal-site
annotate core/modules/comment/src/Plugin/Action/SaveComment.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\comment\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 * Saves a comment. |
Chris@0 | 10 * |
Chris@0 | 11 * @Action( |
Chris@0 | 12 * id = "comment_save_action", |
Chris@0 | 13 * label = @Translation("Save comment"), |
Chris@0 | 14 * type = "comment" |
Chris@0 | 15 * ) |
Chris@0 | 16 */ |
Chris@0 | 17 class SaveComment extends ActionBase { |
Chris@0 | 18 |
Chris@0 | 19 /** |
Chris@0 | 20 * {@inheritdoc} |
Chris@0 | 21 */ |
Chris@0 | 22 public function execute($comment = NULL) { |
Chris@0 | 23 $comment->save(); |
Chris@0 | 24 } |
Chris@0 | 25 |
Chris@0 | 26 /** |
Chris@0 | 27 * {@inheritdoc} |
Chris@0 | 28 */ |
Chris@0 | 29 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { |
Chris@0 | 30 /** @var \Drupal\comment\CommentInterface $object */ |
Chris@0 | 31 return $object->access('update', $account, $return_as_object); |
Chris@0 | 32 } |
Chris@0 | 33 |
Chris@0 | 34 } |