Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/Plugin/Condition/NodeIsPublished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @file
* Contains \Drupal\rules\Plugin\Condition\NodeIsPublished.
*/

namespace Drupal\rules\Plugin\Condition;

use Drupal\Core\Condition\ConditionPluginBase;

/**
* Provides a 'Node Is Published' condition.
*
* @Condition(
* id = "rules_node_is_published",
* label = @Translation("Node is published"),
* context = {
* "node" = {
* "type" = "entity",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be "entity:node" instead without the whole constraints stuff. That's simpler and should be used instead.

* "constraints" = {
* "EntityType" = "node"
* }
* }
* }
* )
*
* @todo: Add access callback information from Drupal 7.
* @todo: Add group information from Drupal 7.
*/
class NodeIsPublished extends ConditionPluginBase {

/**
* {@inheritdoc}
*/
public function summary() {
return t('Node is published.');
}

/**
* {@inheritdoc}
*/
public function evaluate() {
$node = $this->getContextValue('node');
return $node->isPublished();
}

}