> */ private $data = []; private ServiceFactory $serviceFactory; public function __construct(ServiceFactory $serviceFactory) { $this->serviceFactory = $serviceFactory; } /** * @return Service<\Espo\ORM\Entity> * @throws Error */ public function get(string $entityType): Service { if (!array_key_exists($entityType, $this->data)) { $this->load($entityType); } return $this->data[$entityType]; } private function load(string $entityType): void { $this->data[$entityType] = $this->serviceFactory->create($entityType); } }