[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_templates/src/Field/ -> TemplatenameField.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_templates
   6   *
   7   * @copyright   (C) 2015 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\Templates\Administrator\Field;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Field\ListField;
  15  use Joomla\Component\Templates\Administrator\Helper\TemplatesHelper;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Template Name field.
  23   *
  24   * @since  3.5
  25   */
  26  class TemplatenameField extends ListField
  27  {
  28      /**
  29       * The form field type.
  30       *
  31       * @var    string
  32       * @since  3.5
  33       */
  34      protected $type = 'TemplateName';
  35  
  36      /**
  37       * Method to get the field options.
  38       *
  39       * @return  array  The field option objects.
  40       *
  41       * @since   1.6
  42       */
  43      public function getOptions()
  44      {
  45          // Get the client_id filter from the user state.
  46          $clientId = Factory::getApplication()->getUserStateFromRequest('com_templates.styles.client_id', 'client_id', '0', 'string');
  47  
  48          // Get the templates for the selected client_id.
  49          $options = TemplatesHelper::getTemplateOptions($clientId);
  50  
  51          // Merge into the parent options.
  52          return array_merge(parent::getOptions(), $options);
  53      }
  54  }


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