lazyLoadEntity(); } /** * @return EntityInterface|null */ private function lazyLoadEntity(): ?EntityInterface { if ($this->isLazyLoadNeccessary()) { $entity = parent::loadEntity(); self::$lazyLoadedEntity = $entity; } return self::$lazyLoadedEntity; } /** * @return bool */ private function isLazyLoadNeccessary(): bool { if (self::$lazyLoadedEntity) { if ($this->hasId()) { return $this->id !== self::$lazyLoadedEntity->getId(); } if ($this->hasSlug()) { if (self::$lazyLoadedEntity instanceof SlugAttributInterface) { return $this->slug !== self::$lazyLoadedEntity->getSlug(); } } } return true; } }