[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_scheduler/src/Helper/ -> SchedulerHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_scheduler
   6   *
   7   * @copyright   (C) 2021 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\Scheduler\Administrator\Helper;
  12  
  13  use Joomla\CMS\Application\AdministratorApplication;
  14  use Joomla\CMS\Event\AbstractEvent;
  15  use Joomla\CMS\Factory;
  16  use Joomla\CMS\Plugin\PluginHelper;
  17  use Joomla\Component\Scheduler\Administrator\Task\TaskOptions;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * The SchedulerHelper class.
  25   * Provides static methods used across com_scheduler
  26   *
  27   * @since  4.1.0
  28   */
  29  abstract class SchedulerHelper
  30  {
  31      /**
  32       * Cached TaskOptions object
  33       *
  34       * @var  TaskOptions
  35       * @since  4.1.0
  36       */
  37      protected static $taskOptionsCache;
  38  
  39      /**
  40       * Returns available task routines as a TaskOptions object.
  41       *
  42       * @return  TaskOptions  A TaskOptions object populated with task routines offered by plugins
  43       *
  44       * @since  4.1.0
  45       * @throws  \Exception
  46       */
  47      public static function getTaskOptions(): TaskOptions
  48      {
  49          if (self::$taskOptionsCache !== null) {
  50              return self::$taskOptionsCache;
  51          }
  52  
  53          /** @var  AdministratorApplication $app */
  54          $app     = Factory::getApplication();
  55          $options = new TaskOptions();
  56          $event   = AbstractEvent::create(
  57              'onTaskOptionsList',
  58              [
  59                  'subject' => $options,
  60              ]
  61          );
  62  
  63          PluginHelper::importPlugin('task');
  64          $app->getDispatcher()->dispatch('onTaskOptionsList', $event);
  65  
  66          self::$taskOptionsCache = $options;
  67  
  68          return $options;
  69      }
  70  }


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