NodeMakeSticky.php
Namespace
Drupal\rules\Plugin\RulesActionFile
-
src/
Plugin/ RulesAction/ NodeMakeSticky.php
View source
<?php
namespace Drupal\rules\Plugin\RulesAction;
use Drupal\node\NodeInterface;
use Drupal\rules\Core\RulesActionBase;
/**
* Makes a content item sticky.
*
* @RulesAction(
* id = "rules_node_make_sticky",
* label = @Translation("Make selected content sticky"),
* category = @Translation("Content"),
* context_definitions = {
* "node" = @ContextDefinition("entity:node",
* label = @Translation("Node"),
* description = @Translation("Specifies the content item to make sticky."),
* assignment_restriction = "selector"
* ),
* }
* )
*/
class NodeMakeSticky extends RulesActionBase {
/**
* Executes the action with the given context.
*
* @param \Drupal\node\NodeInterface $node
* The node to modify.
*/
protected function doExecute(NodeInterface $node) {
$node->setSticky(NodeInterface::STICKY);
}
/**
* {@inheritdoc}
*/
public function autoSaveContext() {
// The node should be auto-saved after the execution.
return [
'node',
];
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
NodeMakeSticky | Makes a content item sticky. |