3 namespace Drupal\node\Plugin\Action;
5 use Drupal\Core\Action\ActionBase;
6 use Drupal\Core\Session\AccountInterface;
12 * id = "node_promote_action",
13 * label = @Translation("Promote selected content to front page"),
17 class PromoteNode extends ActionBase {
22 public function execute($entity = NULL) {
23 $entity->setPromoted(TRUE);
30 public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
31 /** @var \Drupal\node\NodeInterface $object */
32 $access = $object->access('update', $account, TRUE)
33 ->andif($object->promote->access('edit', $account, TRUE));
34 return $return_as_object ? $access : $access->isAllowed();