Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
AbstractSource Class Reference
Inheritance diagram for AbstractSource:
SourceInterface ArrayInterface OptionSourceInterface View Type Layout Mode Page Sortby Countryofmanufacture Layout Status Layout Page Stock Boolean Config Table StockStatus Type Customer Product Theme

Public Member Functions

 setAttribute ($attribute)
 
 getAttribute ()
 
 getOptionText ($value)
 
 getOptionId ($value)
 
 addValueSortToCollection ($collection, $dir=\Magento\Framework\Data\Collection::SORT_ORDER_DESC)
 
 getFlatColumns ()
 
 getFlatIndexes ()
 
 getFlatUpdateSelect ($store)
 
 getIndexOptionText ($value)
 
 toOptionArray ()
 
- Public Member Functions inherited from SourceInterface
 getAllOptions ()
 

Protected Attributes

 $_attribute
 
 $_options = null
 

Detailed Description

Entity/Attribute/Model - attribute selection source abstract

@api

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m @SuppressWarnings(PHPMD.NumberOfChildren)
Since
100.0.2

Definition at line 16 of file AbstractSource.php.

Member Function Documentation

◆ addValueSortToCollection()

addValueSortToCollection (   $collection,
  $dir = \Magento\Framework\Data\Collection::SORT_ORDER_DESC 
)

Add Value Sort To Collection Select

Parameters
\Magento\Eav\Model\Entity\Collection\AbstractCollection$collection
string$dirdirection
Returns
$this @SuppressWarnings(PHPMD.UnusedFormalParameter) @codeCoverageIgnore

Definition at line 105 of file AbstractSource.php.

106  {
107  return $this;
108  }

◆ getAttribute()

getAttribute ( )

Get attribute instance

Returns
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute @codeCoverageIgnore

Definition at line 53 of file AbstractSource.php.

◆ getFlatColumns()

getFlatColumns ( )

Retrieve flat column definition

@codeCoverageIgnore

Returns
array

Definition at line 116 of file AbstractSource.php.

117  {
118  return [];
119  }

◆ getFlatIndexes()

getFlatIndexes ( )

Retrieve Indexes(s) for Flat

Returns
array @codeCoverageIgnore

Definition at line 127 of file AbstractSource.php.

128  {
129  return [];
130  }

◆ getFlatUpdateSelect()

getFlatUpdateSelect (   $store)

Retrieve Select For Flat Attribute update

Parameters
int$store
Returns
\Magento\Framework\DB\Select|null @SuppressWarnings(PHPMD.UnusedFormalParameter) @codeCoverageIgnore

Definition at line 140 of file AbstractSource.php.

141  {
142  return null;
143  }

◆ getIndexOptionText()

getIndexOptionText (   $value)

Get a text for index option value

Parameters
string | int$value
Returns
string|bool @codeCoverageIgnore

Definition at line 152 of file AbstractSource.php.

153  {
154  return $this->getOptionText($value);
155  }
$value
Definition: gender.phtml:16

◆ getOptionId()

getOptionId (   $value)
Parameters
string$value
Returns
null|string

Definition at line 86 of file AbstractSource.php.

87  {
88  foreach ($this->getAllOptions() as $option) {
89  if (strcasecmp($option['label'], $value) == 0 || $option['value'] == $value) {
90  return $option['value'];
91  }
92  }
93  return null;
94  }
$value
Definition: gender.phtml:16

◆ getOptionText()

getOptionText (   $value)

Get a text for option value

Parameters
string | int$value
Returns
string|bool

Implements SourceInterface.

Definition at line 64 of file AbstractSource.php.

65  {
66  $options = $this->getAllOptions();
67  // Fixed for tax_class_id and custom_design
68  if (sizeof($options) > 0) {
69  foreach ($options as $option) {
70  if (isset($option['value']) && $option['value'] == $value) {
71  return isset($option['label']) ? $option['label'] : $option['value'];
72  }
73  }
74  }
75  // End
76  if (isset($options[$value])) {
77  return $options[$value];
78  }
79  return false;
80  }
$value
Definition: gender.phtml:16

◆ setAttribute()

setAttribute (   $attribute)

Set attribute instance

Parameters
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute$attribute
Returns
\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend @codeCoverageIgnore

Definition at line 41 of file AbstractSource.php.

42  {
43  $this->_attribute = $attribute;
44  return $this;
45  }

◆ toOptionArray()

toOptionArray ( )

Get options as array

Returns
array @codeCoverageIgnore

Implements OptionSourceInterface.

Definition at line 163 of file AbstractSource.php.

164  {
165  return $this->getAllOptions();
166  }

Field Documentation

◆ $_attribute

$_attribute
protected

Definition at line 25 of file AbstractSource.php.

◆ $_options

$_options = null
protected

Definition at line 32 of file AbstractSource.php.


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