[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_users/src/View/ -> SiteTemplateTrait.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_users
   6   *
   7   * @copyright   (C) 2022 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\Users\Administrator\View;
  12  
  13  use Exception;
  14  use Joomla\CMS\Component\ComponentHelper;
  15  use Joomla\CMS\Factory;
  16  use ReflectionException;
  17  use ReflectionObject;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Dynamically modify the frontend template when showing a MFA captive page.
  25   *
  26   * @since 4.2.0
  27   */
  28  trait SiteTemplateTrait
  29  {
  30      /**
  31       * Set a specific site template style in the frontend application
  32       *
  33       * @return  void
  34       * @throws  Exception
  35       * @since   4.2.0
  36       */
  37      private function setSiteTemplateStyle(): void
  38      {
  39          $app           = Factory::getApplication();
  40          $templateStyle = (int) ComponentHelper::getParams('com_users')->get('captive_template', '');
  41  
  42          if (empty($templateStyle) || !$app->isClient('site')) {
  43              return;
  44          }
  45  
  46          $itemId = $app->input->get('Itemid');
  47  
  48          if (!empty($itemId)) {
  49              return;
  50          }
  51  
  52          $app->input->set('templateStyle', $templateStyle);
  53  
  54          try {
  55              $refApp      = new ReflectionObject($app);
  56              $refTemplate = $refApp->getProperty('template');
  57              $refTemplate->setAccessible(true);
  58              $refTemplate->setValue($app, null);
  59          } catch (ReflectionException $e) {
  60              return;
  61          }
  62  
  63          $template = $app->getTemplate(true);
  64  
  65          $app->set('theme', $template->template);
  66          $app->set('themeParams', $template->params);
  67      }
  68  }


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