[add] Employee code length as setting

This commit is contained in:
Jose Pabl Domingo Aramburo Sanchez 2018-08-06 01:00:31 -06:00
parent 69b636620a
commit 90f11867a5
3 changed files with 12 additions and 3 deletions

View File

@ -6,7 +6,9 @@ class EmployeeApplication{
private $cryptographyService;
private $asserts;
function __construct($mysql, $cryptographyService, $asserts){
function __construct($employeeSettings, $mysql, $cryptographyService, $asserts){
$this->settings = $employeeSettings;
$this->cryptographyService = $cryptographyService;
$this->pdo = $mysql;
$this->asserts = $asserts;
@ -135,7 +137,7 @@ class EmployeeApplication{
$idNewPerson = $this->saveNewPerson($securedFirstName, $securedMiddleName, $securedLastName,
$birthDate, $securedEmail, $phone);
$employeeCode = $this->cryptographyService->pseudoRandomStringOpenssl(10);
$employeeCode = $this->cryptographyService->pseudoRandomStringOpenssl($this->settings['codeLength']);
$idEmployee = $this->savePersonAsEmployee($idEmployeeType, $idNewPerson, $employeeCode, $contractType);
$response = array(

View File

@ -65,6 +65,8 @@ $container['sessionApplication'] = function ($c) {
// The employee application
$container['employeeApplication'] = function ($c) {
$employeeApplication = new App\Application\EmployeeApplication($c['mysql'], $c['cryptographyService'], $c['asserts']);
$employeeSettings = $c->get('settings')['employee'];
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
$c['mysql'], $c['cryptographyService'], $c['asserts']);
return $employeeApplication;
};

View File

@ -40,5 +40,10 @@ return [
'databaseSelectQueryErrorMessage' => 'There was an error fetching the data.',
'databaseInsertQueryErrorMessage' => 'There was an error inserting the record.',
],
// Employee settings
'employee' => [
'codeLength' => '5',
],
],
];