partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit df67c3b7418ac622318529062cfefe269a3597aa
parent ff004a9f4045427bba6cca494d0899c47ffb11f7
Author: Timo A. Hummel <felicitus@felicitus.org>
Date:   Fri,  6 Nov 2015 22:37:23 +0100

Added documentation to parameters.php.dist, read autologin from symfony parameters. Related to #459

Diffstat:
Mapp/config/parameters.php.dist | 39+++++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/FrontendBundle/Controller/IndexController.php | 15++++++++++++---
2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/app/config/parameters.php.dist b/app/config/parameters.php.dist @@ -1,11 +1,50 @@ <?php + +/** + * Specifies the database driver. Available options are listed on this page: + * http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#driver + */ $container->setParameter('database_driver', 'pdo_mysql'); + +/** + * Specifies the hostname for the database + */ $container->setParameter('database_host', 'localhost'); +/** + * Specifies the database port. + */ $container->setParameter('database_port', '3306'); + +/** + * Specifies the database name + */ $container->setParameter('database_name', 'symfony'); + +/** + * Specifies the username for the database + */ $container->setParameter('database_user', 'root'); + +/** + * Specifies the password for the database + */ $container->setParameter('database_password', null); +/** + * Specifies if the frontend should perform an auto-login + */ +$container->setParameter('partkeepr.frontend.auto_login.enabled', false); + +/** + * Specifies the auto-login username + */ +$container->setParameter('partkeepr.frontend.auto_login.username', 'admin'); + +/** + * Specifies the auto-login password + */ +$container->setParameter('partkeepr.frontend.auto_login.password', 'admin'); + $container->setParameter('mailer_transport', null); $container->setParameter('mailer_host', null); diff --git a/src/PartKeepr/FrontendBundle/Controller/IndexController.php b/src/PartKeepr/FrontendBundle/Controller/IndexController.php @@ -37,9 +37,10 @@ class IndexController extends Controller $aParameters["availableImageFormats"] = array("JPG", "GIF", "PNG"); /* Automatic Login */ - if (Configuration::getOption("partkeepr.frontend.autologin.enabled", false) === true) { - $aParameters["autoLoginUsername"] = Configuration::getOption("partkeepr.frontend.autologin.username"); - $aParameters["autoLoginPassword"] = Configuration::getOption("partkeepr.frontend.autologin.password"); + + if ($this->getParameterWithDefault("partkeepr.frontend.auto_login.enabled", false) === true) { + $aParameters["autoLoginUsername"] = $this->getParameter("partkeepr.frontend.auto_login.username"); + $aParameters["autoLoginPassword"] = $this->getParameter("partkeepr.frontend.auto_login.password"); } if (Configuration::getOption("partkeepr.frontend.motd", false) !== false) { @@ -65,4 +66,12 @@ class IndexController extends Controller return $this->render('PartKeeprFrontendBundle::index.html.twig', $renderParams); } + + public function getParameterWithDefault ($name, $default) { + if ($this->container->hasParameter($name)) { + return $this->container->getParameter($name); + } else { + return $default; + } + } }