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