class RemovePublishingDate in Scheduler 2.x
Same name and namespace in other branches
- 8 scheduler_rules_integration/src/Plugin/RulesAction/RemovePublishingDate.php \Drupal\scheduler_rules_integration\Plugin\RulesAction\RemovePublishingDate
Provides a 'Remove date for scheduled publishing' action.
Plugin annotation
@RulesAction(
id = "scheduler_remove_publishing_date",
deriver = "Drupal\scheduler_rules_integration\Plugin\RulesAction\SchedulerRulesActionDeriver"
)
Hierarchy
- class \Drupal\scheduler_rules_integration\Plugin\RulesAction\SchedulerRulesActionBase extends \Drupal\rules\Core\RulesActionBase
- class \Drupal\scheduler_rules_integration\Plugin\RulesAction\RemovePublishingDate
Expanded class hierarchy of RemovePublishingDate
1 file declares its use of RemovePublishingDate
- LegacyRemovePublishingDate.php in scheduler_rules_integration/
src/ Plugin/ RulesAction/ Legacy/ LegacyRemovePublishingDate.php
File
- scheduler_rules_integration/
src/ Plugin/ RulesAction/ RemovePublishingDate.php, line 15
Namespace
Drupal\scheduler_rules_integration\Plugin\RulesActionView source
class RemovePublishingDate extends SchedulerRulesActionBase {
/**
* Remove the publish_on date from the entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity from which to remove the scheduled date.
*/
public function doExecute(EntityInterface $entity) {
$config = \Drupal::config('scheduler.settings');
$bundle_field = $entity
->getEntityType()
->get('entity_keys')['bundle'];
if ($entity->{$bundle_field}->entity
->getThirdPartySetting('scheduler', 'publish_enable', $config
->get('default_publish_enable'))) {
$entity
->set('publish_on', NULL);
scheduler_entity_presave($entity);
}
else {
// The action cannot be executed because the content type is not enabled
// for scheduled publishing.
$this
->notEnabledWarning($entity, 'publish');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RemovePublishingDate:: |
public | function | Remove the publish_on date from the entity. | |
SchedulerRulesActionBase:: |
protected | property | The entity type id. | |
SchedulerRulesActionBase:: |
public static | function | ||
SchedulerRulesActionBase:: |
public | function | Gives a warning when an entity is not enabled for Scheduler. | |
SchedulerRulesActionBase:: |
public | function | Constructs a SchedulerRulesActionBase object. |