You are here

public function UnpublishNow::doExecute in Scheduler 2.x

Same name and namespace in other branches
  1. 8 scheduler_rules_integration/src/Plugin/RulesAction/UnpublishNow.php \Drupal\scheduler_rules_integration\Plugin\RulesAction\UnpublishNow::doExecute()

Set the entity status to Unpublished.

This action is provided by the Rules Module but only for node content, not Media. There is also a problem with recursion in the Rules action due to autoSaveContext(). Hence better for Scheduler to provide this action.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to be unpublished.

File

scheduler_rules_integration/src/Plugin/RulesAction/UnpublishNow.php, line 27

Class

UnpublishNow
Provides an 'Unpublish immediately' action.

Namespace

Drupal\scheduler_rules_integration\Plugin\RulesAction

Code

public function doExecute(EntityInterface $entity) {
  $entity
    ->setUnpublished();
}