public function SchedulerManager::getThirdPartySetting in Scheduler 2.x
Get third-party setting for and entity type, via the entity object.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity.
string $setting: The setting to retrieve.
mixed $default: The default value for setting if none is found.
Return value
mixed The value of the setting.
2 calls to SchedulerManager::getThirdPartySetting()
- SchedulerManager::publish in src/
SchedulerManager.php - Publish scheduled entities.
- SchedulerManager::unpublish in src/
SchedulerManager.php - Unpublish scheduled entities.
File
- src/
SchedulerManager.php, line 808
Class
- SchedulerManager
- Defines a scheduler manager.
Namespace
Drupal\schedulerCode
public function getThirdPartySetting(EntityInterface $entity, $setting, $default) {
$typeFieldName = $this
->getPlugin($entity
->getEntityTypeId())
->typeFieldName();
if (empty($entity->{$typeFieldName})) {
// Avoid exception and give details if the typeFieldName does not exist.
$params = [
'%field' => $typeFieldName,
'%id' => $this
->getPlugin($entity
->getEntityTypeId())
->getPluginId(),
'%entity' => $entity
->getEntityTypeId(),
];
\Drupal::messenger()
->addError($this
->t("Field '%field' specified by typeFieldName in the Scheduler plugin %id is not found in entity type %entity", $params));
$this->logger
->error("Field '%field' specified by typeFieldName in the Scheduler plugin %id is not found in entity type %entity", $params);
return $default;
}
else {
return $entity->{$typeFieldName}->entity
->getThirdPartySetting('scheduler', $setting, $default);
}
}