Skip to content

Commit

Permalink
[GeneratorBundle] Added fos user config to generator (#2427)
Browse files Browse the repository at this point in the history
* added fos user config to generator

* update documentation
  • Loading branch information
Devolicious committed Apr 18, 2019
1 parent c1f29ae commit e6c0c90
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 9 deletions.
Binary file modified docs/images/config-generator.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/installation/index.md
Expand Up @@ -73,6 +73,7 @@ Next we will enter the `Kunstmaan config generator`. It will ask you if you want
* Security: `config/packages/security.yaml`
* Liip Imagine: `config/packages/liip_imagine.yaml`
* Fos Http Cache: `config/packages/prod/fos_http_cache.yaml`
* Fos User: `config/packages/fos_user.yaml`

We suggest that you overwrite it during a new installation, but if you are upgrading you also can choose not to overwrite and then it wil generate a `package-name.yaml.example` file. You can then do a manual comparison of the existing file and the newly created example and make the necessary changes. For now, we just stick with the defaults.

Expand Down
65 changes: 57 additions & 8 deletions src/Kunstmaan/GeneratorBundle/Command/GenerateConfigCommand.php
Expand Up @@ -10,6 +10,9 @@
*/
class GenerateConfigCommand extends KunstmaanGenerateCommand
{
/** @var string */
private $projectDir;

/** @var bool */
private $overwriteSecurity;

Expand All @@ -19,6 +22,9 @@ class GenerateConfigCommand extends KunstmaanGenerateCommand
/** @var bool */
private $overwriteFosHttpCache;

/** @var bool */
private $overwriteFosUser;

/**
* @param string $projectDir
*/
Expand All @@ -35,9 +41,30 @@ public function __construct(string $projectDir)
protected function configure()
{
$this->setDescription('Generates all needed config files not generated by recipes')
->addOption('overwrite-security', '', InputOption::VALUE_REQUIRED, 'Whether the command should generate an example or just overwrite the already existing config file')
->addOption('overwrite-liipimagine', '', InputOption::VALUE_REQUIRED, 'Whether the command should generate an example or just overwrite the already existing config file')
->addOption('overwrite-foshttpcache', '', InputOption::VALUE_REQUIRED, 'Whether the command should generate an example or just overwrite the already existing config file')
->addOption(
'overwrite-security',
'',
InputOption::VALUE_REQUIRED,
'Whether the command should generate an example or just overwrite the already existing config file'
)
->addOption(
'overwrite-liipimagine',
'',
InputOption::VALUE_REQUIRED,
'Whether the command should generate an example or just overwrite the already existing config file'
)
->addOption(
'overwrite-foshttpcache',
'',
InputOption::VALUE_REQUIRED,
'Whether the command should generate an example or just overwrite the already existing config file'
)
->addOption(
'overwrite-fosuser',
'',
InputOption::VALUE_REQUIRED,
'Whether the command should generate an example or just overwrite the already existing config file'
)
->setName('kuma:generate:config');
}

Expand All @@ -56,7 +83,13 @@ protected function doExecute()
{
$this->assistant->writeSection('Config generation');

$this->createGenerator()->generate($this->projectDir, $this->overwriteSecurity, $this->overwriteLiipImagine, $this->overwriteFosHttpCache);
$this->createGenerator()->generate(
$this->projectDir,
$this->overwriteSecurity,
$this->overwriteLiipImagine,
$this->overwriteFosHttpCache,
$this->overwriteFosUser
);

$this->assistant->writeSection('Config successfully created', 'bg=green;fg=black');
}
Expand All @@ -66,20 +99,36 @@ protected function doExecute()
*/
protected function doInteract()
{
$this->assistant->writeLine(array("This helps you to set all default config files needed to run KunstmaanCMS.\n"));
$this->assistant->writeLine(["This helps you to set all default config files needed to run KunstmaanCMS.\n"]);

$this->overwriteSecurity = $this->assistant->getOptionOrDefault('overwrite-security', null);
$this->overwriteLiipImagine = $this->assistant->getOptionOrDefault('overwrite-liipimagine', null);
$this->overwriteFosHttpCache = $this->assistant->getOptionOrDefault('overwrite-foshttpcache', null);
$this->overwriteFosUser = $this->assistant->getOptionOrDefault('overwrite-fosuser', null);

if (null === $this->overwriteSecurity) {
$this->overwriteSecurity = $this->assistant->askConfirmation('Do you want to overwrite the default security.yaml configuration file? (y/n)', 'y');
$this->overwriteSecurity = $this->assistant->askConfirmation(
'Do you want to overwrite the default security.yaml configuration file? (y/n)',
'y'
);
}
if (null === $this->overwriteLiipImagine) {
$this->overwriteLiipImagine = $this->assistant->askConfirmation('Do you want to overwrite the default liip_imagine.yaml configuration file? (y/n)', 'y');
$this->overwriteLiipImagine = $this->assistant->askConfirmation(
'Do you want to overwrite the default liip_imagine.yaml configuration file? (y/n)',
'y'
);
}
if (null === $this->overwriteFosHttpCache) {
$this->overwriteFosHttpCache = $this->assistant->askConfirmation('Do you want to overwrite the production fos_http_cache.yaml configuration file? (y/n)', 'y');
$this->overwriteFosHttpCache = $this->assistant->askConfirmation(
'Do you want to overwrite the production fos_http_cache.yaml configuration file? (y/n)',
'y'
);
}
if (null === $this->overwriteFosUser) {
$this->overwriteFosUser = $this->assistant->askConfirmation(
'Do you want to overwrite the fos_user.yaml configuration file? (y/n)',
'y'
);
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/Kunstmaan/GeneratorBundle/Generator/ConfigGenerator.php
Expand Up @@ -14,8 +14,9 @@ class ConfigGenerator extends KunstmaanGenerator
* @param bool $overwriteSecurity
* @param bool $overwriteLiipImagine
* @param bool $overwriteFosHttpCache
* @param bool $overwriteFosUser
*/
public function generate(string $projectDir, bool $overwriteSecurity, bool $overwriteLiipImagine, bool $overwriteFosHttpCache)
public function generate(string $projectDir, bool $overwriteSecurity, bool $overwriteLiipImagine, bool $overwriteFosHttpCache, bool $overwriteFosUser)
{
$this->renderSingleFile(
$this->skeletonDir,
Expand All @@ -41,5 +42,13 @@ public function generate(string $projectDir, bool $overwriteSecurity, bool $over
true,
$overwriteFosHttpCache ? 'fos_http_cache.yaml' : 'fos_http_cache.yaml.example'
);
$this->renderSingleFile(
$this->skeletonDir,
$projectDir . '/config/packages/',
'fos_user.yaml',
[],
true,
$overwriteFosUser ? 'fos_user.yaml' : 'fos_user.yaml.example'
);
}
}
@@ -0,0 +1,8 @@
fos_user:
db_driver: orm
firewall_name: main
user_class: Kunstmaan\AdminBundle\Entity\User
# Change this section to your liking
from_email:
address: 'kunstmaancms@myproject.dev'
sender_name: 'KunstmaanCMS'

0 comments on commit e6c0c90

Please sign in to comment.