Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Integer.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class Integer implements FactoryInterface
15 {
21  private static $defaultPadding = [
22  'int' => '11',
23  'tinyint' => '2',
24  'smallint' => '5',
25  'bigint' => '20'
26  ];
27 
31  private $objectManager;
32 
36  private $className;
37 
44  public function __construct(
45  ObjectManagerInterface $objectManager,
46  $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Integer::class
47  ) {
48  $this->objectManager = $objectManager;
49  $this->className = $className;
50  }
51 
55  public function create(array $data)
56  {
57  if (!isset($data['padding'])) {
58  $data['padding'] = self::$defaultPadding[$data['type']];
59  }
60  //Auto increment field can`t be null
61  if (isset($data['identity']) && $data['identity']) {
62  $data['nullable'] = false;
63  }
64 
65  if (isset($data['default'])) {
66  $data['default'] = (int) $data['default'];
67  }
68 
69  return $this->objectManager->create($this->className, $data);
70  }
71 }
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager, $className=\Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Integer::class)
Definition: Integer.php:44