Skip to content
Snippets Groups Projects

Update scheduler.module.

Open Karan Garg requested to merge issue/scheduler-3500296:3500296-able-to-schedule into 2.x
+ 22
0
@@ -805,6 +805,28 @@ function scheduler_entity_base_field_info(EntityTypeInterface $entity_type) {
return $fields;
}
/**
* Implements hook_entity_bundle_field_info_alter().
*/
function scheduler_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
// This is necessary for content types where the title label is changed from
// the default "Title" to something else. In this case, the field are
// considered a bundle field and the constraint must be added here. This is
// expected (not a Drupal bug).
// Additional info: https://www.drupal.org/project/drupal/issues/3193351.
$entity_types = \Drupal::service('scheduler.manager')->getPluginEntityTypes();
if (in_array($entity_type->id(), $entity_types)) {
if (!empty($fields['publish_on'])) {
$fields['publish_on']->addConstraint('SchedulerPublishOn', []);
}
if (!empty($fields['unpublish_on'])) {
$fields['unpublish_on']->addConstraint('SchedulerUnpublishOn', []);
}
}
}
/**
* Implements hook_action_info_alter().
*/
Loading