Commit a15b1d0b authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Move fetching documentation data in new command

The former task was deactivated and therefore the data is not up to date
parent aaac0b23
Pipeline #9357 passed with stages
in 8 minutes and 54 seconds
<?php
namespace T3o\TerFe2\Command;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class FetchDocumentationStatus extends Command
{
/**
* @var string
*/
protected $documentationFileName = 'currentdocumentationdata.json';
/**
* @var string
*/
protected $sourceUrl = 'https://intercept.typo3.com/assets/docs/manuals.json';
protected function configure()
{
$this->setDescription('Fetches the current documentation JSON file for extensions that use intercept');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$sourceData = GeneralUtility::getUrl($this->sourceUrl);
if (json_decode($sourceData, true) !== null) {
$targetFile = Environment::getPublicPath() . '/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . $this->documentationFileName;
if (GeneralUtility::writeFile($targetFile, $sourceData)) {
$io->success('Documentation file has been updated');
} else {
$io->error('Error during update of documentation file');
}
} else {
$io->warning('Source file is not a valid JSON file');
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment