[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_fields/src/Field/ -> FieldcontextsField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_fields
   6   *
   7   * @copyright   (C) 2016 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\Fields\Administrator\Field;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Fields\FieldsServiceInterface;
  15  use Joomla\CMS\Form\Field\ListField;
  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  3.7.0
  25   */
  26  class FieldcontextsField extends ListField
  27  {
  28      /**
  29       * Type of the field
  30       *
  31       * @var    string
  32       */
  33      public $type = 'Fieldcontexts';
  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   3.7.0
  42       */
  43      protected function getInput()
  44      {
  45          return $this->getOptions() ? parent::getInput() : '';
  46      }
  47  
  48      /**
  49       * Method to get the field options.
  50       *
  51       * @return  array  The field option objects.
  52       *
  53       * @since   3.7.0
  54       */
  55      protected function getOptions()
  56      {
  57          $parts = explode('.', $this->value);
  58  
  59          $component = Factory::getApplication()->bootComponent($parts[0]);
  60  
  61          if ($component instanceof FieldsServiceInterface) {
  62              return $component->getContexts();
  63          }
  64  
  65          return [];
  66      }
  67  }


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