AbstractForm.php 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Data source to fill "Forms" field
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Captcha\Model\Config\Form;
  12. use Magento\Framework\App\Config\Value;
  13. abstract class AbstractForm extends Value implements \Magento\Framework\Option\ArrayInterface
  14. {
  15. /**
  16. * @var string
  17. */
  18. protected $_configPath;
  19. /**
  20. * Returns options for form multiselect
  21. *
  22. * @return array
  23. */
  24. public function toOptionArray()
  25. {
  26. $optionArray = [];
  27. $backendConfig = $this->_config->getValue($this->_configPath, 'default');
  28. if ($backendConfig) {
  29. foreach ($backendConfig as $formName => $formConfig) {
  30. if (!empty($formConfig['label'])) {
  31. $optionArray[] = ['label' => $formConfig['label'], 'value' => $formName];
  32. }
  33. }
  34. }
  35. return $optionArray;
  36. }
  37. }