diff --git a/api-payroll/src/application/EmployeeApplication.php b/api-payroll/src/application/EmployeeApplication.php index 46e193a..de8652b 100644 --- a/api-payroll/src/application/EmployeeApplication.php +++ b/api-payroll/src/application/EmployeeApplication.php @@ -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( diff --git a/api-payroll/src/dependencies.php b/api-payroll/src/dependencies.php index cb1fa94..1075e7b 100644 --- a/api-payroll/src/dependencies.php +++ b/api-payroll/src/dependencies.php @@ -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; }; \ No newline at end of file diff --git a/api-payroll/src/settings.php b/api-payroll/src/settings.php index 54893f4..10ea7c9 100644 --- a/api-payroll/src/settings.php +++ b/api-payroll/src/settings.php @@ -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', + ], ], ];