Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RepositoryFactory.php
Go to the documentation of this file.
1 <?php
8 
11 
16 {
22  protected $entities;
23 
29  protected $objectManager;
30 
37  public function __construct(
39  array $entities = []
40  ) {
41  $this->objectManager = $objectManager;
42  $this->entities = $entities;
43  }
44 
50  public function create($entityType)
51  {
52  if (!isset($this->entities[$entityType])) {
53  $message =
54  sprintf('The repository for the "%s" entity type isn\'t declared. Verify and try again.', $entityType);
55  throw new NotFoundException(new \Magento\Framework\Phrase($message));
56  }
57  return $this->objectManager->get($this->entities[$entityType]);
58  }
59 }
__construct(ObjectManagerInterface $objectManager, array $entities=[])
$message