Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Unique.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class Unique implements FactoryInterface
17 {
21  private $objectManager;
22 
26  private $className;
27 
31  private $resourceConnection;
32 
36  private $tableNameResolver;
37 
41  private $elementNameResolver;
42 
52  public function __construct(
53  ObjectManagerInterface $objectManager,
54  ResourceConnection $resourceConnection,
55  TableNameResolver $tableNameResolver,
56  ElementNameResolver $elementNameResolver,
57  $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Constraints\Internal::class
58  ) {
59  $this->objectManager = $objectManager;
60  $this->resourceConnection = $resourceConnection;
61  $this->className = $className;
62  $this->tableNameResolver = $tableNameResolver;
63  $this->elementNameResolver = $elementNameResolver;
64  }
65 
69  public function create(array $data)
70  {
71  $data['nameWithoutPrefix'] = $this->elementNameResolver->getIndexNameWithoutPrefix(
72  $data['name'],
73  $data['table'],
74  $data['column'],
75  $data['type']
76  );
77 
78  return $this->objectManager->create($this->className, $data);
79  }
80 }
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager, ResourceConnection $resourceConnection, TableNameResolver $tableNameResolver, ElementNameResolver $elementNameResolver, $className=\Magento\Framework\Setup\Declaration\Schema\Dto\Constraints\Internal::class)
Definition: Unique.php:52