private function SchedulerManager::throwSchedulerException in Scheduler 2.x
Handles throwing exceptions.
Parameters
Drupal\Core\Entity\EntityInterface $entity: The entity causing the exepction.
string $exception_name: Which exception to throw.
string $process: The process being performed (publish|unpublish).
Throws
\Drupal\scheduler\Exception\SchedulerEntityTypeNotEnabledException
2 calls to SchedulerManager::throwSchedulerException()
- SchedulerManager::publish in src/
SchedulerManager.php - Publish scheduled entities.
- SchedulerManager::unpublish in src/
SchedulerManager.php - Unpublish scheduled entities.
File
- src/
SchedulerManager.php, line 192
Class
- SchedulerManager
- Defines a scheduler manager.
Namespace
Drupal\schedulerCode
private function throwSchedulerException(EntityInterface $entity, $exception_name, $process) {
$plugin = $this
->getPlugin($entity
->getEntityTypeId());
// Exception messages are developer-facing and do not need to be translated
// from English. So it is accpetable to create words such as "{$process}ed"
// and "{$process}ing".
switch ($exception_name) {
case 'SchedulerEntityTypeNotEnabledException':
$message = "'%s' (id %d) was not %s because %s %s '%s' is not enabled for scheduled %s. One of the following hook functions added the id incorrectly: %s. Processing halted";
$p1 = $entity
->label();
$p2 = $entity
->id();
$p3 = "{$process}ed";
$p4 = $entity
->getEntityTypeId();
$p5 = $plugin
->typeFieldName();
$p6 = $entity->{$plugin
->typeFieldName()}->entity
->label();
$p7 = "{$process}ing";
// Get a list of the hook function implementations, as one of these will
// have caused this exception.
$hooks = array_merge($this
->getHookImplementations('list', $entity), $this
->getHookImplementations('list_alter', $entity));
asort($hooks);
$p8 = implode(', ', $hooks);
break;
}
$class = "\\Drupal\\scheduler\\Exception\\{$exception_name}";
throw new $class(sprintf($message, $p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8));
}