function scheduler_feeds_processor_targets_alter in Scheduler 8
Same name and namespace in other branches
- 7 scheduler.module \scheduler_feeds_processor_targets_alter()
- 2.x scheduler.module \scheduler_feeds_processor_targets_alter()
Implements hook_feeds_processor_targets_alter().
This function exposes publish_on and unpublish_on as mappable targets to the Feeds module.
@todo Port to Drupal 8.
See also
https://www.drupal.org/node/2651354
File
- ./
scheduler.module, line 659 - Scheduler publishes and unpublishes nodes on dates specified by the user.
Code
function scheduler_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
$config = \Drupal::config('scheduler.settings');
// Scheduler module only works on nodes.
if ($entity_type == 'node') {
$publishing_enabled = $entity_type
->getThirdPartySetting('scheduler', 'publish_enable', $config
->get('default_publish_enable'));
$unpublishing_enabled = $entity_type
->getThirdPartySetting('scheduler', 'unpublish_enable', $config
->get('default_unpublish_enable'));
if ($publishing_enabled) {
$targets['publish_on'] = [
'name' => t('Scheduler: publish on'),
'description' => t('The date when the Scheduler module will publish the node.'),
'callback' => 'scheduler_feeds_set_target',
];
}
if ($unpublishing_enabled) {
$targets['unpublish_on'] = [
'name' => t('Scheduler: unpublish on'),
'description' => t('The date when the Scheduler module will unpublish the node.'),
'callback' => 'scheduler_feeds_set_target',
];
}
}
}