public function SchedulerRulesActionBase::notEnabledWarning in Scheduler 2.x
Gives a warning when an entity is not enabled for Scheduler.
This is called from actions that attempt to set or remove a Scheduler date value when the entity type is not enabled for that process.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object being processed by the action.
string $process: The process that is not enabled, either 'publish' or 'unpublish'.
4 calls to SchedulerRulesActionBase::notEnabledWarning()
- RemovePublishingDate::doExecute in scheduler_rules_integration/
src/ Plugin/ RulesAction/ RemovePublishingDate.php - Remove the publish_on date from the entity.
- RemoveUnpublishingDate::doExecute in scheduler_rules_integration/
src/ Plugin/ RulesAction/ RemoveUnpublishingDate.php - Remove the unpublish_on date from the entity.
- SetPublishingDate::doExecute in scheduler_rules_integration/
src/ Plugin/ RulesAction/ SetPublishingDate.php - Set the publish_on date on the entity.
- SetUnpublishingDate::doExecute in scheduler_rules_integration/
src/ Plugin/ RulesAction/ SetUnpublishingDate.php - Set the unpublish_on date on the entity.
File
- scheduler_rules_integration/
src/ Plugin/ RulesAction/ SchedulerRulesActionBase.php, line 59
Class
- SchedulerRulesActionBase
- Provides base class on which all Scheduler Rules actions are built.
Namespace
Drupal\scheduler_rules_integration\Plugin\RulesActionCode
public function notEnabledWarning(EntityInterface $entity, string $process) {
$action = $this
->summary();
$activity = $process == 'publish' ? $this
->t('scheduled publishing') : $this
->t('scheduled unpublishing');
$condition = $this
->t('@bundle_label is enabled for @activity', [
'@bundle_label' => $entity
->getEntityType()
->getBundleLabel(),
'@activity' => $activity,
]);
$bundle_field = $entity
->getEntityType()
->get('entity_keys')['bundle'];
$type_name = $entity->{$bundle_field}->entity
->label();
$type_id = $entity->{$bundle_field}->entity
->bundle();
$url = new Url("entity.{$type_id}.edit_form", [
$type_id => $entity
->bundle(),
]);
$arguments = [
'%action' => "'{$action}'",
'@activity' => $activity,
'%type' => $type_name,
'@group' => $entity
->getEntityType()
->getPluralLabel(),
'%condition' => "'{$condition}'",
'@url' => $url
->toString(),
];
$link = Link::fromTextAndUrl($this
->t('@type settings', [
'@type' => $type_name,
]), $url)
->toString();
\Drupal::logger('scheduler')
->warning('Action %action is not valid because @activity is not enabled for %type @group. Add the condition %condition to your Reaction Rule, or enable @activity via the %type settings.', $arguments + [
'link' => $link,
]);
\Drupal::messenger()
->addMessage($this
->t('Action %action is not valid because @activity is not enabled for %type @group. Add the condition %condition to your Reaction Rule, or enable @activity via the <a href="@url">%type</a> settings.', $arguments), 'warning', FALSE);
}