Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
MultiSelectConfigOption Class Reference
Inheritance diagram for MultiSelectConfigOption:
AbstractConfigOption

Public Member Functions

 __construct ( $name, $frontendType, array $selectOptions, $configPath, $description='', array $defaultValue=[], $shortCut=null)
 
 getSelectOptions ()
 
 validate ($data)
 
- Public Member Functions inherited from AbstractConfigOption
 __construct ( $name, $frontendType, $mode, $configPath, $description='', $defaultValue=null, $shortcut=null)
 
 getFrontendType ()
 
 getConfigPath ()
 
 validate ($data)
 

Data Fields

const FRONTEND_WIZARD_CHECKBOX = 'checkbox'
 
const FRONTEND_WIZARD_MULTISELECT = 'multiselect'
 

Detailed Description

Multi-select option in deployment config tool

Definition at line 11 of file MultiSelectConfigOption.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name,
  $frontendType,
array  $selectOptions,
  $configPath,
  $description = '',
array  $defaultValue = [],
  $shortCut = null 
)

Constructor

Parameters
string$name
string$frontendType
array$selectOptions
string$configPath
string$description
array$defaultValue
string | array | null$shortCut
Exceptions

Definition at line 35 of file MultiSelectConfigOption.php.

43  {
44  if ($frontendType != self::FRONTEND_WIZARD_MULTISELECT && $frontendType != self::FRONTEND_WIZARD_CHECKBOX) {
45  throw new \InvalidArgumentException(
46  "Frontend input type has to be 'multiselect', 'textarea' or 'checkbox'."
47  );
48  }
49  if (!$selectOptions) {
50  throw new \InvalidArgumentException('Select options can\'t be empty.');
51  }
52  $this->selectOptions = $selectOptions;
53  parent::__construct(
54  $name,
55  $frontendType,
56  self::VALUE_REQUIRED | self::VALUE_IS_ARRAY,
57  $configPath,
59  $defaultValue,
60  $shortCut
61  );
62  }
$selectOptions
if(!isset($_GET['name'])) $name
Definition: log.php:14

Member Function Documentation

◆ getSelectOptions()

getSelectOptions ( )

Get available options

Returns
array

Definition at line 69 of file MultiSelectConfigOption.php.

70  {
71  return $this->selectOptions;
72  }
$selectOptions

◆ validate()

validate (   $data)

Validates input data

Parameters
mixed$data
Returns
void
Exceptions

Definition at line 81 of file MultiSelectConfigOption.php.

82  {
83  if (is_array($data)) {
84  foreach ($data as $value) {
85  if (!in_array($value, $this->getSelectOptions())) {
86  throw new \InvalidArgumentException(
87  "Value specified for '{$this->getName()}' is not supported: '{$value}'"
88  );
89  }
90  }
91  }
92  parent::validate($data);
93  }
$value
Definition: gender.phtml:16

Field Documentation

◆ FRONTEND_WIZARD_CHECKBOX

const FRONTEND_WIZARD_CHECKBOX = 'checkbox'

#+ Frontend input types

Definition at line 16 of file MultiSelectConfigOption.php.

◆ FRONTEND_WIZARD_MULTISELECT

const FRONTEND_WIZARD_MULTISELECT = 'multiselect'

Definition at line 17 of file MultiSelectConfigOption.php.


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