![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Setup/Option/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Setup\Option; /** * Select option in deployment config tool */ class SelectConfigOption extends AbstractConfigOption { /**#@+ * Frontend input types */ const FRONTEND_WIZARD_RADIO = 'radio'; const FRONTEND_WIZARD_SELECT = 'select'; /**#@- */ /**#@- */ private $selectOptions; /** * Constructor * * @param string $name * @param string $frontendType * @param array $selectOptions * @param string $configPath * @param string $description * @param string|null $defaultValue * @param string|array|null $shortCut * @throws \InvalidArgumentException */ public function __construct( $name, $frontendType, array $selectOptions, $configPath, $description = '', $defaultValue = null, $shortCut = null ) { if ($frontendType != self::FRONTEND_WIZARD_SELECT && $frontendType != self::FRONTEND_WIZARD_RADIO) { throw new \InvalidArgumentException("Frontend input type has to be 'select' or 'radio'."); } if (!$selectOptions) { throw new \InvalidArgumentException('Select options can\'t be empty.'); } $this->selectOptions = $selectOptions; parent::__construct( $name, $frontendType, self::VALUE_REQUIRED, $configPath, $description, $defaultValue, $shortCut ); } /** * Get available options * * @return array */ public function getSelectOptions() { return $this->selectOptions; } /** * Validates input data * * @param mixed $data * @return void * @throws \InvalidArgumentException */ public function validate($data) { if (!in_array($data, $this->getSelectOptions())) { throw new \InvalidArgumentException("Value specified for '{$this->getName()}' is not supported: '{$data}'"); } parent::validate($data); } }