public function ConfigHelper::getEntity in Lightning Core 8.2
Same name and namespace in other branches
- 8.5 src/ConfigHelper.php \Drupal\lightning_core\ConfigHelper::getEntity()
- 8 src/ConfigHelper.php \Drupal\lightning_core\ConfigHelper::getEntity()
- 8.3 src/ConfigHelper.php \Drupal\lightning_core\ConfigHelper::getEntity()
- 8.4 src/ConfigHelper.php \Drupal\lightning_core\ConfigHelper::getEntity()
Transparently loads a config entity from the extension's config.
Parameters
string $entity_type: The entity type ID.
string $id: The entity ID.
bool $force: (optional) If TRUE, the entity is read from config even if it already exists. Defaults to FALSE.
Return value
\Drupal\Core\Entity\EntityInterface|null The config entity, or NULL if it doesn't exist.
1 call to ConfigHelper::getEntity()
- ConfigHelper::delete in src/
ConfigHelper.php - Overrides Drupal\Core\Config\FileStorage::delete().
File
- src/
ConfigHelper.php, line 92
Class
- ConfigHelper
- A facade to assist with manipulating default config.
Namespace
Drupal\lightning_coreCode
public function getEntity($entity_type, $id, $force = FALSE) {
$storage = $this->entityTypeManager
->getStorage($entity_type);
$entity = $storage
->load($id);
if ($entity && empty($force)) {
return $entity;
}
$prefixes = $this
->getConfigPrefixes();
return $storage
->create($this
->read($prefixes[$entity_type] . '.' . $id));
}