[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Console/ -> CheckUpdatesCommand.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Console;
  11  
  12  use Joomla\CMS\Updater\Updater;
  13  use Joomla\Console\Command\AbstractCommand;
  14  use Symfony\Component\Console\Command\Command;
  15  use Symfony\Component\Console\Input\InputInterface;
  16  use Symfony\Component\Console\Output\OutputInterface;
  17  use Symfony\Component\Console\Style\SymfonyStyle;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('JPATH_PLATFORM') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Console command for checking if there are pending extension updates
  25   *
  26   * @since  4.0.0
  27   */
  28  class CheckUpdatesCommand extends AbstractCommand
  29  {
  30      /**
  31       * The default command name
  32       *
  33       * @var    string
  34       * @since  4.0.0
  35       */
  36      protected static $defaultName = 'update:extensions:check';
  37  
  38      /**
  39       * Internal function to execute the command.
  40       *
  41       * @param   InputInterface   $input   The input to inject into the command.
  42       * @param   OutputInterface  $output  The output to inject into the command.
  43       *
  44       * @return  integer  The command exit code
  45       *
  46       * @since   4.0.0
  47       */
  48      protected function doExecute(InputInterface $input, OutputInterface $output): int
  49      {
  50          $symfonyStyle = new SymfonyStyle($input, $output);
  51  
  52          $symfonyStyle->title('Fetching Extension Updates');
  53  
  54          // Find all updates
  55          $ret = Updater::getInstance()->findUpdates();
  56  
  57          if ($ret) {
  58              $symfonyStyle->note('There are available updates to apply');
  59              $symfonyStyle->success('Check complete.');
  60          } else {
  61              $symfonyStyle->success('There are no available updates');
  62          }
  63  
  64          return Command::SUCCESS;
  65      }
  66  
  67      /**
  68       * Configure the command.
  69       *
  70       * @return  void
  71       *
  72       * @since   4.0.0
  73       */
  74      protected function configure(): void
  75      {
  76          $help = "<info>%command.name%</info> command checks for pending extension updates
  77          \nUsage: <info>php %command.full_name%</info>";
  78  
  79          $this->setDescription('Check for pending extension updates');
  80          $this->setHelp($help);
  81      }
  82  }


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