[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_associations/src/Field/ -> ItemtypeField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_associations
   6   *
   7   * @copyright   (C) 2017 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\Associations\Administrator\Field;
  12  
  13  use Joomla\CMS\Form\Field\GroupedlistField;
  14  use Joomla\CMS\HTML\HTMLHelper;
  15  use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * A drop down containing all component item types that implement associations.
  23   *
  24   * @since  3.7.0
  25   */
  26  class ItemtypeField extends GroupedlistField
  27  {
  28      /**
  29       * The form field type.
  30       *
  31       * @var    string
  32       *
  33       * @since  3.7.0
  34       */
  35      protected $type = 'Itemtype';
  36  
  37      /**
  38       * Method to get the field input markup.
  39       *
  40       * @return  array  The field option objects as a nested array in groups.
  41       *
  42       * @since  3.7.0
  43       *
  44       * @throws  \UnexpectedValueException
  45       */
  46      protected function getGroups()
  47      {
  48          $options    = array();
  49          $extensions = AssociationsHelper::getSupportedExtensions();
  50  
  51          foreach ($extensions as $extension) {
  52              if ($extension->get('associationssupport') === true) {
  53                  foreach ($extension->get('types') as $type) {
  54                      $context = $extension->get('component') . '.' . $type->get('name');
  55                      $options[$extension->get('title')][] = HTMLHelper::_('select.option', $context, $type->get('title'));
  56                  }
  57              }
  58          }
  59  
  60          // Sort by alpha order.
  61          uksort($options, 'strnatcmp');
  62  
  63          // Add options to parent array.
  64          return array_merge(parent::getGroups(), $options);
  65      }
  66  }


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