class EntityDataRepository
Hierarchy
- class \mglaman\PHPStanDrupal\Drupal\EntityDataRepository
Expanded class hierarchy of EntityDataRepository
4 files declare their use of EntityDataRepository
- DrupalStaticEntityQueryDynamicReturnTypeExtension.php in vendor/
mglaman/ phpstan-drupal/ src/ Type/ DrupalStaticEntityQueryDynamicReturnTypeExtension.php - EntityRepositoryReturnTypeExtension.php in vendor/
mglaman/ phpstan-drupal/ src/ Type/ EntityRepositoryReturnTypeExtension.php - EntityStorageDynamicReturnTypeExtension.php in vendor/
mglaman/ phpstan-drupal/ src/ Type/ EntityStorage/ EntityStorageDynamicReturnTypeExtension.php - EntityTypeManagerGetStorageDynamicReturnTypeExtension.php in vendor/
mglaman/ phpstan-drupal/ src/ Type/ EntityTypeManagerGetStorageDynamicReturnTypeExtension.php
File
-
vendor/
mglaman/ phpstan-drupal/ src/ Drupal/ EntityDataRepository.php, line 10
Namespace
mglaman\PHPStanDrupal\DrupalView source
final class EntityDataRepository {
/**
* @var array<string, EntityData>
*/
private $entityData;
public function __construct(array $entityMapping) {
foreach ($entityMapping as $entityTypeId => $entityData) {
$this->entityData[$entityTypeId] = new EntityData($entityTypeId, $entityData);
}
}
public function get(string $entityTypeId) : EntityData {
if (!isset($this->entityData[$entityTypeId])) {
$this->entityData[$entityTypeId] = new EntityData($entityTypeId, []);
}
return $this->entityData[$entityTypeId];
}
public function resolveFromStorage(ObjectType $callerType) : ?EntityData {
if ($callerType->equals(new ObjectType(EntityStorageInterface::class))) {
return null;
}
if ($callerType->equals(new ObjectType(ConfigEntityStorageInterface::class))) {
return null;
}
if ($callerType->equals(new ObjectType(ContentEntityStorageInterface::class))) {
return null;
}
foreach ($this->entityData as $entityData) {
$storageType = $entityData->getStorageType();
if ($storageType !== null && $callerType->isSuperTypeOf($storageType)
->yes()) {
return $entityData;
}
}
return null;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EntityDataRepository::$entityData | private | property | |
EntityDataRepository::get | public | function | |
EntityDataRepository::resolveFromStorage | public | function | |
EntityDataRepository::__construct | public | function |