objectManager = $objectManager; $this->entities = $entities; } /** * @param string $entityType * @return object * @throws NotFoundException */ public function create($entityType) { if (!isset($this->entities[$entityType])) { $message = sprintf('The repository for the "%s" entity type isn\'t declared. Verify and try again.', $entityType); throw new NotFoundException(new \Magento\Framework\Phrase($message)); } return $this->objectManager->get($this->entities[$entityType]); } }