CoreFiles by mySites.guru
CheckUpdatesCommand.php82 lines, 2,010 bytes, from Joomla_4.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta
md5
9e8e156aa33ca17877cb790188dc0650
sha1
43684ad070736ba46a26903520b941aa00510d47
sha256
849d7e6cb0e89533b30dfced67a1170097ce1d676cd86855149a9e5d29f7ad7a
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Console;

\defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Updater\Updater;
use Joomla\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
 * Console command for checking if there are pending extension updates
 *
 * @since  4.0.0
 */
class CheckUpdatesCommand extends AbstractCommand
{
	/**
	 * The default command name
	 *
	 * @var    string
	 * @since  4.0.0
	 */
	protected static $defaultName = 'update:extensions:check';

	/**
	 * Internal function to execute the command.
	 *
	 * @param   InputInterface   $input   The input to inject into the command.
	 * @param   OutputInterface  $output  The output to inject into the command.
	 *
	 * @return  integer  The command exit code
	 *
	 * @since   4.0.0
	 */
	protected function doExecute(InputInterface $input, OutputInterface $output): int
	{
		$symfonyStyle = new SymfonyStyle($input, $output);

		$symfonyStyle->title('Fetching Extension Updates');

		// Get the update cache time
		$component = ComponentHelper::getComponent('com_installer');

		$cache_timeout = 3600 * (int) $component->getParams()->get('cachetimeout', 6);

		// Find all updates
		Updater::getInstance()->findUpdates(0, $cache_timeout);

		$symfonyStyle->success('Finished fetching updates');

		return 0;
	}

	/**
	 * Configure the command.
	 *
	 * @return  void
	 *
	 * @since   4.0.0
	 */
	protected function configure(): void
	{
		$this->setDescription('Check for pending extension updates');
		$this->setHelp(
			<<<EOF
The <info>%command.name%</info> command checks for pending extension updates

<info>php %command.full_name%</info>
EOF
		);
	}
}

The same content is in 2 releases, Joomla 4.0.0-beta to 4.0.0-beta2. See them all, or every version of this file.