Skip to content

Commit

Permalink
afup#1416 bdd
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jan 8, 2024
1 parent 070bc40 commit 567e765
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 33 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
- name: Composer install
run: composer install --no-scripts

- name: Config file
run: make configs/application/config.php

- name: Parameters file
run: make app/config/parameters.yml

- name: Tests - Unit
run: ./bin/atoum

Expand Down Expand Up @@ -66,7 +72,7 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-
- name: CS fixer prerequisites
- name: Config file
run: make configs/application/config.php

- name: Composer install
Expand Down Expand Up @@ -100,9 +106,12 @@ jobs:
restore-keys: |
${{ runner.os }}-composer-
- name: Prerequisites
- name: Config file
run: make configs/application/config.php

- name: Parameters file
run: make app/config/parameters.yml

- name: Composer install
run: composer install --no-scripts --ignore-platform-req=php

Expand Down
4 changes: 0 additions & 4 deletions configs/application/config-test.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php
$configuration['bdd']['hote']='dbtest';
$configuration['bdd']['base']='web';
$configuration['bdd']['utilisateur']='afup';
$configuration['bdd']['mot_de_passe']='afup';
$configuration['web']['path']='/';

$configuration['divers']['niveau_erreur']='32767';
Expand Down
4 changes: 0 additions & 4 deletions configs/application/config.php.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php
$configuration['bdd']['hote']='127.0.0.1';
$configuration['bdd']['base']='afup_dev';
$configuration['bdd']['utilisateur']='afup_dev';
$configuration['bdd']['mot_de_passe']='p455w0rd';
$configuration['web']['path']='http://.dev/';

$configuration['divers']['niveau_erreur']='6143';
Expand Down
4 changes: 0 additions & 4 deletions configs/application/config.php.dist-docker
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php
$configuration['bdd']['hote']='db';
$configuration['bdd']['base']='web';
$configuration['bdd']['utilisateur']='afup';
$configuration['bdd']['mot_de_passe']='afup';
$configuration['web']['path']='/';

$configuration['divers']['niveau_erreur']='6143';
Expand Down
10 changes: 0 additions & 10 deletions htdocs/pages/administration/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@

$formulaire->setDefaults($defaults);

$formulaire->addElement('header', '' , 'Base de données');
$formulaire->addElement('text' , 'bdd|hote' , 'Hote' , array('size' => 30));
$formulaire->addElement('text' , 'bdd|base' , 'Base' , array('size' => 30));
$formulaire->addElement('text' , 'bdd|utilisateur' , 'Utilisateur' , array('size' => 30));
$formulaire->addElement('text' , 'bdd|mot_de_passe', 'Mot de passe' , array('size' => 30));

$formulaire->addElement('header' , '' , 'Mails');
$formulaire->addElement('text' , 'mails|email_expediteur' , 'Email expediteur' , array('size' => 30));
$formulaire->addElement('text' , 'mails|nom_expediteur' , 'Nom expediteur' , array('size' => 30));
Expand Down Expand Up @@ -55,10 +49,6 @@
$formulaire->addElement('header', 'boutons' , '');
$formulaire->addElement('submit', 'soumettre', 'Enregistrer');

$formulaire->addRule('bdd|hote' , 'Hote manquant' , 'required');
$formulaire->addRule('bdd|base' , 'Base manquante' , 'required');
$formulaire->addRule('bdd|utilisateur', 'Utilisateur manquant', 'required');

if ($formulaire->validate()) {
$valeurs = $formulaire->exportValues();
$conf->importer($valeurs);
Expand Down
8 changes: 8 additions & 0 deletions sources/Afup/Utils/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public function __construct($chemin_fichier)
{
$this->_chemin_fichier = $chemin_fichier;
$this->_valeurs = include($this->_chemin_fichier);

$kernel = new SymfonyKernel();
$container = $kernel->getKernel()->getContainer();

$this->_valeurs['bdd']['hote'] = $container->getParameter('database_host');
$this->_valeurs['bdd']['base'] = $container->getParameter('database_name');
$this->_valeurs['bdd']['utilisateur'] = $container->getParameter('database_user');
$this->_valeurs['bdd']['mot_de_passe'] = $container->getParameter('database_password');
}

/**
Expand Down
10 changes: 1 addition & 9 deletions sources/Afup/Utils/SymfonyKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public function __construct(Request $request = null)
$env = 'prod';
$debug = false;

$configuration = $this->getLegacyConfig();

if ($configuration['divers']['afficher_erreurs']) {
if (isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'dev') {
Debug::enable(E_WARNING);
$debug = true;
$env = 'dev';
Expand All @@ -41,12 +39,6 @@ public function __construct(Request $request = null)
$this->request = $request;
}

private function getLegacyConfig()
{
// $configuration comes from this file
return include(__DIR__ . '/../../../configs/application/config.php');
}

/**
* @param string $uri
* @return void
Expand Down

0 comments on commit 567e765

Please sign in to comment.