[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/console/src/Event/ -> BeforeCommandExecuteEvent.php (source)

   1  <?php
   2  /**
   3   * Part of the Joomla Framework Console Package
   4   *
   5   * @copyright  Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
   6   * @license    GNU General Public License version 2 or later; see LICENSE
   7   */
   8  
   9  namespace Joomla\Console\Event;
  10  
  11  use Joomla\Console\Application;
  12  use Joomla\Console\Command\AbstractCommand;
  13  use Joomla\Console\ConsoleEvents;
  14  
  15  /**
  16   * Event triggered before a command is executed.
  17   *
  18   * @since  2.0.0
  19   */
  20  class BeforeCommandExecuteEvent extends ConsoleEvent
  21  {
  22      /**
  23       * The return code for a command disabled by this event.
  24       *
  25       * @var    integer
  26       * @since  2.0.0
  27       */
  28      public const RETURN_CODE_DISABLED = 113;
  29  
  30      /**
  31       * Flag indicating the command is enabled
  32       *
  33       * @var    boolean
  34       * @since  2.0.0
  35       */
  36      private $commandEnabled = true;
  37  
  38      /**
  39       * Event constructor.
  40       *
  41       * @param   Application           $application  The active application.
  42       * @param   AbstractCommand|null  $command      The command being executed.
  43       *
  44       * @since   2.0.0
  45       */
  46  	public function __construct(Application $application, ?AbstractCommand $command = null)
  47      {
  48          parent::__construct(ConsoleEvents::BEFORE_COMMAND_EXECUTE, $application, $command);
  49  
  50          if ($command)
  51          {
  52              $this->commandEnabled = $command->isEnabled();
  53          }
  54      }
  55  
  56      /**
  57       * Disable the command.
  58       *
  59       * @return  void
  60       *
  61       * @since   2.0.0
  62       */
  63  	public function disableCommand(): void
  64      {
  65          $this->commandEnabled = false;
  66      }
  67  
  68      /**
  69       * Enable the command.
  70       *
  71       * @return  void
  72       *
  73       * @since   2.0.0
  74       */
  75  	public function enableCommand(): void
  76      {
  77          $this->commandEnabled = false;
  78      }
  79  
  80      /**
  81       * Check if the command is enabled.
  82       *
  83       * @return    boolean
  84       *
  85       * @since   2.0.0
  86       */
  87  	public function isCommandEnabled(): bool
  88      {
  89          return $this->commandEnabled;
  90      }
  91  }


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