Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SelectConfigOption.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  const FRONTEND_WIZARD_RADIO = 'radio';
17  const FRONTEND_WIZARD_SELECT = 'select';
21  private $selectOptions;
22 
35  public function __construct(
36  $name,
37  $frontendType,
38  array $selectOptions,
39  $configPath,
40  $description = '',
41  $defaultValue = null,
42  $shortCut = null
43  ) {
44  if ($frontendType != self::FRONTEND_WIZARD_SELECT && $frontendType != self::FRONTEND_WIZARD_RADIO) {
45  throw new \InvalidArgumentException("Frontend input type has to be 'select' or 'radio'.");
46  }
47  if (!$selectOptions) {
48  throw new \InvalidArgumentException('Select options can\'t be empty.');
49  }
50  $this->selectOptions = $selectOptions;
51  parent::__construct(
52  $name,
53  $frontendType,
54  self::VALUE_REQUIRED,
55  $configPath,
57  $defaultValue,
58  $shortCut
59  );
60  }
61 
67  public function getSelectOptions()
68  {
69  return $this->selectOptions;
70  }
71 
79  public function validate($data)
80  {
81  if (!in_array($data, $this->getSelectOptions())) {
82  throw new \InvalidArgumentException("Value specified for '{$this->getName()}' is not supported: '{$data}'");
83  }
84  parent::validate($data);
85  }
86 }
__construct( $name, $frontendType, array $selectOptions, $configPath, $description='', $defaultValue=null, $shortCut=null)
$selectOptions
if(!isset($_GET['name'])) $name
Definition: log.php:14