[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_workflow/src/Field/ -> WorkflowcontextsField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_workflow
   6   *
   7   * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Workflow\Administrator\Field;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Field\ListField;
  15  use Joomla\CMS\Workflow\WorkflowServiceInterface;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Fields Contexts
  23   *
  24   * @since  4.0.0
  25   */
  26  class WorkflowcontextsField extends ListField
  27  {
  28      /**
  29       * Type of the field
  30       *
  31       * @var    string
  32       */
  33      public $type = 'Workflowcontexts';
  34  
  35      /**
  36       * Method to get the field input markup for a generic list.
  37       * Use the multiple attribute to enable multiselect.
  38       *
  39       * @return  string  The field input markup.
  40       *
  41       * @since   4.0.0
  42       */
  43      protected function getInput()
  44      {
  45          if (count($this->getOptions()) < 2) {
  46              $this->layout = 'joomla.form.field.hidden';
  47          }
  48  
  49          return parent::getInput();
  50      }
  51  
  52      /**
  53       * Method to get the field options.
  54       *
  55       * @return  array  The field option objects.
  56       *
  57       * @since   4.0.0
  58       */
  59      protected function getOptions()
  60      {
  61          $parts = explode('.', $this->value);
  62  
  63          $component = Factory::getApplication()->bootComponent($parts[0]);
  64  
  65          if ($component instanceof WorkflowServiceInterface) {
  66              return $component->getWorkflowContexts();
  67          }
  68  
  69          return [];
  70      }
  71  }


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