public function SchedulerManager::isAllowed in Scheduler 8
Same name and namespace in other branches
- 2.x src/SchedulerManager.php \Drupal\scheduler\SchedulerManager::isAllowed()
Checks whether a scheduled action on a node is allowed.
This provides a way for other modules to prevent scheduled publishing or unpublishing, by implementing hook_scheduler_allow_publishing() or hook_scheduler_allow_unpublishing().
Parameters
\Drupal\node\NodeInterface $node: The node on which the action is to be performed.
string $action: The action that needs to be checked. Can be 'publish' or 'unpublish'.
Return value
bool TRUE if the action is allowed, FALSE if not.
See also
hook_scheduler_allow_publishing()
hook_scheduler_allow_unpublishing()
2 calls to SchedulerManager::isAllowed()
- SchedulerManager::publish in src/
SchedulerManager.php - Publish scheduled nodes.
- SchedulerManager::unpublish in src/
SchedulerManager.php - Unpublish scheduled nodes.
File
- src/
SchedulerManager.php, line 497
Class
- SchedulerManager
- Defines a scheduler manager.
Namespace
Drupal\schedulerCode
public function isAllowed(NodeInterface $node, $action) {
// Default to TRUE.
$result = TRUE;
// Check that other modules allow the action.
$hook = 'scheduler_allow_' . $action . 'ing';
foreach ($this->moduleHandler
->getImplementations($hook) as $module) {
$function = $module . '_' . $hook;
$result &= $function($node);
}
return $result;
}