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