[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_scheduler/src/Task/ -> TaskOptions.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\Task;
  12  
  13  // phpcs:disable PSR1.Files.SideEffects
  14  \defined('_JEXEC') or die;
  15  // phpcs:enable PSR1.Files.SideEffects
  16  
  17  /**
  18   * The TaskOptions class.
  19   * Used as the subject argument for the `onTaskOptionsList` event, plugins that support tasks must add them to the
  20   * object through the addOptions() method.
  21   *
  22   * @since  4.1.0
  23   */
  24  class TaskOptions
  25  {
  26      /**
  27       * An array of TaskOptions
  28       *
  29       * @var TaskOption[]
  30       * @since  4.1.0
  31       */
  32      public $options = [];
  33  
  34      /**
  35       * A plugin can support several task routines
  36       * This method is used by a plugin's onTaskOptionsList subscriber to advertise supported routines.
  37       *
  38       * @param   array  $taskRoutines  An associative array of {@var TaskOption} constructor argument pairs:
  39       *                                [ 'routineId' => 'languageConstantPrefix', ... ]
  40       *
  41       * @return void
  42       *
  43       * @since  4.1.0
  44       */
  45      public function addOptions(array $taskRoutines): void
  46      {
  47          foreach ($taskRoutines as $routineId => $langConstPrefix) {
  48              $this->options[] = new TaskOption($routineId, $langConstPrefix);
  49          }
  50      }
  51  
  52      /**
  53       * @param   ?string  $routineId  A unique identifier for a plugin task routine
  54       *
  55       * @return  ?TaskOption  A matching TaskOption if available, null otherwise
  56       *
  57       * @since  4.1.0
  58       */
  59      public function findOption(?string $routineId): ?TaskOption
  60      {
  61          if ($routineId === null) {
  62              return null;
  63          }
  64  
  65          foreach ($this->options as $option) {
  66              if ($option->id === $routineId) {
  67                  return $option;
  68              }
  69          }
  70  
  71          return null;
  72      }
  73  }


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