-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Expand file tree
/
Copy pathConfig.php
More file actions
50 lines (45 loc) · 1.22 KB
/
Config.php
File metadata and controls
50 lines (45 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Copyright 2013 Adobe
* All Rights Reserved.
*/
namespace Magento\Eav\Model\Entity\Attribute\Source;
/**
* Entity/Attribute/Model - attribute selection source from configuration
*
* this class should be abstract, but kept usual for legacy purposes
*/
class Config extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
/**
* @var array
*/
protected $_optionsData;
/**
* @param array $options
* @codeCoverageIgnore
*/
public function __construct(array $options)
{
$this->_optionsData = $options;
}
/**
* Retrieve all options for the source from configuration
*
* @throws \Magento\Framework\Exception\LocalizedException
* @return array
*/
public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = [];
if (empty($this->_optionsData)) {
throw new \Magento\Framework\Exception\LocalizedException(__('No options found.'));
}
foreach ($this->_optionsData as $option) {
$this->_options[] = ['value' => $option['value'], 'label' => __($option['label'])];
}
}
return $this->_options;
}
}