[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Form/Field/ -> WorkflowComponentSectionsField.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Form\Field;
  11  
  12  use Joomla\CMS\Factory;
  13  use Joomla\CMS\HTML\HTMLHelper;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\Workflow\WorkflowServiceInterface;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('JPATH_PLATFORM') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Form Field class for the Joomla Framework.
  23   *
  24   * @since  4.0.0
  25   */
  26  class WorkflowComponentSectionsField extends ComponentsField
  27  {
  28      /**
  29       * The form field type.
  30       *
  31       * @var     string
  32       * @since  4.0.0
  33       */
  34      protected $type = 'WorkflowComponentSections';
  35  
  36      /**
  37       * Method to get a list of options for a list input.
  38       *
  39       * @return  array  An array of JHtml options.
  40       *
  41       * @since   4.0.0
  42       */
  43      protected function getOptions()
  44      {
  45          $app       = Factory::getApplication();
  46          $items     = parent::getOptions();
  47          $options   = [];
  48          $options[] = HTMLHelper::_('select.option', ' ', Text::_('JNONE'));
  49  
  50          foreach ($items as $item) {
  51              if (substr($item->value, 0, 4) !== 'com_') {
  52                  continue;
  53              }
  54  
  55              $component = $app->bootComponent($item->value);
  56  
  57              if (!($component instanceof WorkflowServiceInterface)) {
  58                  continue;
  59              }
  60  
  61              foreach ($component->getWorkflowContexts() as $extension => $text) {
  62                  $options[] = HTMLHelper::_('select.option', $extension, Text::sprintf('JWORKFLOW_FIELD_COMPONENT_SECTIONS_TEXT', $item->text, $text));
  63              }
  64          }
  65  
  66          return $options;
  67      }
  68  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer