protected function Switcher::getConfigEntity in Configuration selector 8.2
Same name and namespace in other branches
- 8 src/Controller/Switcher.php \Drupal\config_selector\Controller\Switcher::getConfigEntity()
Gets a valid configuration entity to work with.
Parameters
\Drupal\config_selector\Entity\FeatureInterface $config_selector_feature: The Configuration selector feature.
string $config_entity_type: The entity type of the configuration entity we are switching to.
string $config_entity_id: The ID of the configuration entity we are switching to.
Return value
\Drupal\Core\Config\Entity\ConfigEntityInterface|false The configuration entity we are switching to, or FALSE if invalid.
1 call to Switcher::getConfigEntity()
- Switcher::select in src/
Controller/ Switcher.php - Selects the supplied configuration entity.
File
- src/
Controller/ Switcher.php, line 75
Class
- Switcher
- Allows the UI to switch between different configuration entities.
Namespace
Drupal\config_selector\ControllerCode
protected function getConfigEntity(FeatureInterface $config_selector_feature, $config_entity_type, $config_entity_id) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $config_entity */
$config_entity = $this
->entityTypeManager()
->getStorage($config_entity_type)
->load($config_entity_id);
if (!$config_entity) {
$this
->messenger()
->addWarning($this
->t('Configuration entity of type %type and ID $id does not exist.', [
'%type' => $config_entity_type,
'%id' => $config_entity_id,
]));
return FALSE;
}
if ($config_entity
->getThirdPartySetting('config_selector', 'feature') !== $config_selector_feature
->id()) {
$this
->messenger()
->addWarning($this
->t('Configuration entity %config_label is not part of the %feature_label feature.', [
'%config_label' => $config_entity
->label(),
'%feature_label' => $config_selector_feature
->label(),
]));
return FALSE;
}
return $config_entity;
}