public function UnpublishByKeywordNode::execute in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php \Drupal\node\Plugin\Action\UnpublishByKeywordNode::execute()
Executes the plugin.
Overrides ExecutableInterface::execute
File
- core/
modules/ node/ src/ Plugin/ Action/ UnpublishByKeywordNode.php, line 29 - Contains \Drupal\node\Plugin\Action\UnpublishByKeywordNode.
Class
- UnpublishByKeywordNode
- Unpublishes a node containing certain keywords.
Namespace
Drupal\node\Plugin\ActionCode
public function execute($node = NULL) {
foreach ($this->configuration['keywords'] as $keyword) {
$elements = node_view(clone $node);
if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node
->label(), $keyword) !== FALSE) {
$node
->setPublished(FALSE);
$node
->save();
break;
}
}
}