[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Dispatcher/ -> ModuleDispatcher.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  namespace Joomla\CMS\Dispatcher;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('_JEXEC') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Base class for a Joomla Module Dispatcher
  18   *
  19   * Executes the single entry file of a module.
  20   *
  21   * @since  4.0.0
  22   */
  23  class ModuleDispatcher extends AbstractModuleDispatcher
  24  {
  25      /**
  26       * Dispatches the dispatcher.
  27       *
  28       * @return  void
  29       *
  30       * @since   4.0.0
  31       */
  32      public function dispatch()
  33      {
  34          $path = JPATH_BASE . '/modules/' . $this->module->module . '/' . $this->module->module . '.php';
  35  
  36          if (!is_file($path)) {
  37              return;
  38          }
  39  
  40          $this->loadLanguage();
  41  
  42          // Execute the layout without the module context
  43          $loader = static function ($path, array $displayData) {
  44              // If $displayData doesn't exist in extracted data, unset the variable.
  45              if (!\array_key_exists('displayData', $displayData)) {
  46                  extract($displayData);
  47                  unset($displayData);
  48              } else {
  49                  extract($displayData);
  50              }
  51  
  52              include $path;
  53          };
  54  
  55          $loader($path, $this->getLayoutData());
  56      }
  57  }


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