Skip to content

Commit

Permalink
[FEATURE] Add action to fix example site config
Browse files Browse the repository at this point in the history
Since TYPO3 messes up the base when being called from CLI
we add an action which can optionally reset it to a /
  • Loading branch information
helhum committed Aug 16, 2019
1 parent 7f8308d commit 5f98557
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/Install/Action/FixupSiteConfigAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
namespace Helhum\TYPO3\ConfigHandling\Install\Action;

/***************************************************************
* Copyright notice
*
* (c) 2018 Helmut Hummel <[email protected]>
* All rights reserved
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the text file GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Helhum\Typo3Console\Install\Action\InstallActionInterface;
use Helhum\Typo3Console\Mvc\Cli\CommandDispatcher;
use Helhum\Typo3Console\Mvc\Cli\ConsoleOutput;
use Symfony\Component\Yaml\Yaml;

class FixupSiteConfigAction implements InstallActionInterface
{

public function setOutput(ConsoleOutput $output)
{
$this->output = $output;
}

public function setCommandDispatcher(CommandDispatcher $commandDispatcher = null)
{
$this->commandDispatcher = $commandDispatcher;
}

public function shouldExecute(array $actionDefinition, array $options = []): bool
{
return true;
}

public function execute(array $actionDefinition, array $options = []): bool
{
$siteConfigFile = getenv('TYPO3_PATH_APP') . '/config/sites/main/config.yaml';
if (!file_exists($siteConfigFile)) {
return true;
}
$siteConfig = Yaml::parse(file_get_contents($siteConfigFile));
$siteConfig['base'] = '/';
file_put_contents($siteConfigFile, Yaml::dump($siteConfig, 99));

return true;
}
}

0 comments on commit 5f98557

Please sign in to comment.