Skip to content
Snippets Groups Projects
Commit 9382d0a3 authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

Don't thorow needless exception

parent c753ec18
No related branches found
No related tags found
1 merge request!112Don't throw needless exception
......@@ -29,15 +29,9 @@ final class ReferenceUpgrader {
* Registers entities.
*/
public function registerEntity(EntityInterface $entity) {
$entityId = $entity->id() ?? $this->throwNeedsId();
$this->entities[$entity->getEntityTypeId()][$entityId] = $entity;
}
/**
* Throws exceptions on trying to register entities without id.
*/
private function throwNeedsId() {
throw new \RuntimeException("Can only register entity with ID.");
if ($entityId = $entity->id()) {
$this->entities[$entity->getEntityTypeId()][$entityId] = $entity;
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment