Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
QuoteSetup Class Reference
Inheritance diagram for QuoteSetup:
EavSetup

Public Member Functions

 __construct (ModuleDataSetupInterface $setup, Context $context, CacheInterface $cache, CollectionFactory $attrGroupCollectionFactory, ScopeConfigInterface $config)
 
 addAttribute ($entityTypeId, $code, array $attr)
 
 getConfigModel ()
 
 getEncryptor ()
 
 getConnection ()
 
 getTable ($table)
 
- Public Member Functions inherited from EavSetup
 __construct (ModuleDataSetupInterface $setup, Context $context, CacheInterface $cache, CollectionFactory $attrGroupCollectionFactory)
 
 getSetup ()
 
 getAttributeGroupCollectionFactory ()
 
 cleanCache ()
 
 installDefaultGroupIds ()
 
 addEntityType ($code, array $params)
 
 updateEntityType ($code, $field, $value=null)
 
 getEntityType ($id, $field=null)
 
 getEntityTypeId ($entityTypeId)
 
 removeEntityType ($id)
 
 getAttributeSetSortOrder ($entityTypeId, $sortOrder=null)
 
 addAttributeSet ($entityTypeId, $name, $sortOrder=null, $setId=null)
 
 updateAttributeSet ($entityTypeId, $id, $field, $value=null)
 
 getAttributeSet ($entityTypeId, $id, $field=null)
 
 getAttributeSetId ($entityTypeId, $setId)
 
 removeAttributeSet ($entityTypeId, $id)
 
 setDefaultSetToEntityType ($entityType, $attributeSet='Default')
 
 getAllAttributeSetIds ($entityTypeId=null)
 
 getDefaultAttributeSetId ($entityType)
 
 getAttributeGroupSortOrder ($entityTypeId, $setId, $sortOrder=null)
 
 addAttributeGroup ($entityTypeId, $setId, $name, $sortOrder=null)
 
 convertToAttributeGroupCode ($groupName)
 
 updateAttributeGroup ($entityTypeId, $setId, $id, $field, $value=null)
 
 getAttributeGroup ($entityTypeId, $setId, $id, $field=null)
 
 getAttributeGroupByCode ($entityTypeId, $setId, $code, $field=null)
 
 getAttributeGroupId ($entityTypeId, $setId, $groupId)
 
 removeAttributeGroup ($entityTypeId, $setId, $id)
 
 getDefaultAttributeGroupId ($entityType, $attributeSetId=null)
 
 getAttributesNumberInGroup ($entityTypeId, $setId, $groupId)
 
 addAttribute ($entityTypeId, $code, array $attr)
 
 addAttributeOption ($option)
 
 updateAttribute ($entityTypeId, $id, $field, $value=null, $sortOrder=null)
 
 getAttribute ($entityTypeId, $id, $field=null)
 
 getAttributeId ($entityTypeId, $id)
 
 getAttributeTable ($entityTypeId, $id)
 
 removeAttribute ($entityTypeId, $code)
 
 getAttributeSortOrder ($entityTypeId, $setId, $groupId, $sortOrder=null)
 
 addAttributeToSet ($entityTypeId, $setId, $groupId, $attributeId, $sortOrder=null)
 
 addAttributeToGroup ($entityType, $setId, $groupId, $attributeId, $sortOrder=null)
 
 getDefaultEntities ()
 
 installEntities ($entities=null)
 

Protected Member Functions

 _flatTableExist ($table)
 
 _addFlatAttribute ($table, $attribute, $attr)
 
 _getAttributeColumnDefinition ($code, $data)
 

Protected Attributes

 $_config
 
 $_encryptor
 
 $_flatEntityTables
 

Detailed Description

Quote module setup class

@SuppressWarnings(PHPMD.CyclomaticComplexity) @codeCoverageIgnore

Definition at line 21 of file QuoteSetup.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ModuleDataSetupInterface  $setup,
Context  $context,
CacheInterface  $cache,
CollectionFactory  $attrGroupCollectionFactory,
ScopeConfigInterface  $config 
)
Parameters
ModuleDataSetupInterface$setup
Context$context
CacheInterface$cache
CollectionFactory$attrGroupCollectionFactory
ScopeConfigInterface$config

Definition at line 45 of file QuoteSetup.php.

51  {
52  $this->_config = $config;
53  $this->_encryptor = $context->getEncryptor();
54  parent::__construct($setup, $context, $cache, $attrGroupCollectionFactory);
55  }
$config
Definition: fraud_order.php:17
$setup
Definition: trigger.php:12

Member Function Documentation

◆ _addFlatAttribute()

_addFlatAttribute (   $table,
  $attribute,
  $attr 
)
protected

Add attribute as separate column in the table

Parameters
string$table
string$attribute
array$attr
Returns
$this

Definition at line 117 of file QuoteSetup.php.

118  {
119  $tableInfo = $this->getConnection()
120  ->describeTable($this->getTable($table));
121  if (isset($tableInfo[$attribute])) {
122  return $this;
123  }
124  $columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
125  $this->getConnection()->addColumn(
126  $this->getTable($table),
127  $attribute,
128  $columnDefinition
129  );
130  return $this;
131  }
_getAttributeColumnDefinition($code, $data)
Definition: QuoteSetup.php:141
$attr
Definition: text.phtml:8
$table
Definition: trigger.php:14

◆ _flatTableExist()

_flatTableExist (   $table)
protected

Check if table exist for flat entity

Parameters
string$table
Returns
bool

Definition at line 77 of file QuoteSetup.php.

78  {
79  $tablesList = $this->getConnection()->listTables();
80  return in_array(
81  strtoupper($this->getTable($table)),
82  array_map('strtoupper', $tablesList)
83  );
84  }
$table
Definition: trigger.php:14

◆ _getAttributeColumnDefinition()

_getAttributeColumnDefinition (   $code,
  $data 
)
protected

Retrieve definition of column for create in flat table

Parameters
string$code
array$data
Returns
array @SuppressWarnings(PHPMD.NPathComplexity)

Definition at line 141 of file QuoteSetup.php.

142  {
143  // Convert attribute type to column info
144  $data['type'] = isset($data['type']) ? $data['type'] : 'varchar';
145  $type = null;
146  $length = null;
147  switch ($data['type']) {
148  case 'timestamp':
150  break;
151  case 'datetime':
153  break;
154  case 'decimal':
156  $length = '12,4';
157  break;
158  case 'int':
160  break;
161  case 'text':
163  $length = 65536;
164  break;
165  case 'char':
166  case 'varchar':
168  $length = 255;
169  break;
170  }
171  if ($type !== null) {
172  $data['type'] = $type;
173  $data['length'] = $length;
174  }
175 
176  $data['nullable'] = isset($data['required']) ? !$data['required'] : true;
177  $data['comment'] = isset($data['comment']) ? $data['comment'] : ucwords(str_replace('_', ' ', $code));
178  return $data;
179  }
$type
Definition: item.phtml:13
$code
Definition: info.phtml:12

◆ addAttribute()

addAttribute (   $entityTypeId,
  $code,
array  $attr 
)

Add entity attribute. Overwritten for flat entities support

Parameters
int | string$entityTypeId
string$code
array$attr
Returns
$this

Definition at line 94 of file QuoteSetup.php.

95  {
96  if (isset(
97  $this->_flatEntityTables[$entityTypeId]
98  ) && $this->_flatTableExist(
99  $this->_flatEntityTables[$entityTypeId]
100  )
101  ) {
102  $this->_addFlatAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr);
103  } else {
104  parent::addAttribute($entityTypeId, $code, $attr);
105  }
106  return $this;
107  }
$attr
Definition: text.phtml:8
_addFlatAttribute($table, $attribute, $attr)
Definition: QuoteSetup.php:117
$code
Definition: info.phtml:12

◆ getConfigModel()

getConfigModel ( )

Get config model

Returns
ScopeConfigInterface

Definition at line 186 of file QuoteSetup.php.

187  {
188  return $this->_config;
189  }

◆ getConnection()

getConnection ( )

Get quote connection

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Definition at line 204 of file QuoteSetup.php.

205  {
206  return $this->getSetup()->getConnection(self::$connectionName);
207  }

◆ getEncryptor()

getEncryptor ( )
Returns
\Magento\Framework\Encryption\EncryptorInterface

Definition at line 194 of file QuoteSetup.php.

195  {
196  return $this->_encryptor;
197  }

◆ getTable()

getTable (   $table)

Get table name

Parameters
string$table
Returns
string

Definition at line 215 of file QuoteSetup.php.

216  {
217  return $this->getSetup()->getTable($table, self::$connectionName);
218  }
$table
Definition: trigger.php:14

Field Documentation

◆ $_config

$_config
protected

Definition at line 26 of file QuoteSetup.php.

◆ $_encryptor

$_encryptor
protected

Definition at line 31 of file QuoteSetup.php.

◆ $_flatEntityTables

$_flatEntityTables
protected
Initial value:
= [
'quote' => 'quote',
'quote_item' => 'quote_item',
'quote_address' => 'quote_address',
'quote_address_item' => 'quote_address_item',
'quote_address_rate' => 'quote_shipping_rate',
'quote_payment' => 'quote_payment',
]

Definition at line 62 of file QuoteSetup.php.


The documentation for this class was generated from the following file: