-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add action to fix example site config
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
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |