Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
db-anonym
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
db-anonym
Commits
c9cef487
Commit
c9cef487
authored
Jan 26, 2022
by
Bertrand Gauthier
Browse files
Options
Downloads
Patches
Plain Diff
Déplacement de certaines vérif de la config
parent
36fd289a
No related branches found
No related tags found
No related merge requests found
Pipeline
#12339
passed
Jan 26, 2022
Stage: publish
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenDbfakator/Service/DbfakatorService.php
+0
-7
0 additions, 7 deletions
src/UnicaenDbfakator/Service/DbfakatorService.php
src/UnicaenDbfakator/Service/DbfakatorServiceFactory.php
+25
-4
25 additions, 4 deletions
src/UnicaenDbfakator/Service/DbfakatorServiceFactory.php
with
25 additions
and
11 deletions
src/UnicaenDbfakator/Service/DbfakatorService.php
+
0
−
7
View file @
c9cef487
...
...
@@ -63,9 +63,6 @@ class DbfakatorService
*/
public
function
setConfig
(
array
$config
):
self
{
Assert
::
keyExists
(
$config
,
$k
=
'entities'
,
"La config du module doit posséder la clé '
$k
'"
);
Assert
::
keyExists
(
$config
,
$k
=
'output'
,
"La config du module doit posséder la clé '
$k
'"
);
$this
->
entitiesConfig
=
$config
[
'entities'
];
$this
->
outputConfig
=
$config
[
'output'
];
...
...
@@ -84,15 +81,11 @@ class DbfakatorService
public
function
getAnonymisationScriptPath
()
{
Assert
::
keyExists
(
$this
->
outputConfig
,
$k
=
'anonymisation'
,
"La config 'output' doit posséder la clé '
$k
'"
);
return
$this
->
outputConfig
[
'anonymisation'
];
}
public
function
getRestaurationScriptPath
()
{
Assert
::
keyExists
(
$this
->
outputConfig
,
$k
=
'restauration'
,
"La config 'output' doit posséder la clé '
$k
'"
);
return
$this
->
outputConfig
[
'restauration'
];
}
...
...
This diff is collapsed.
Click to expand it.
src/UnicaenDbfakator/Service/DbfakatorServiceFactory.php
+
25
−
4
View file @
c9cef487
...
...
@@ -3,6 +3,7 @@
namespace
UnicaenDbfakator\Service
;
use
Psr\Container\ContainerInterface
;
use
Webmozart\Assert\Assert
;
class
DbfakatorServiceFactory
{
...
...
@@ -15,16 +16,36 @@ class DbfakatorServiceFactory
*/
public
function
__invoke
(
ContainerInterface
$container
):
DbfakatorService
{
/** @var array $config */
$config
=
$container
->
get
(
'Config'
);
/** @var \Doctrine\ORM\EntityManager $em */
$em
=
$container
->
get
(
'doctrine.entitymanager.orm_default'
);
$config
=
$this
->
getConfig
(
$container
);
$service
=
new
DbfakatorService
();
$service
->
setConfig
(
$config
[
'unicaen-dbfakator'
]
??
[]
);
$service
->
setConfig
(
$config
);
$service
->
setEntityManager
(
$em
);
return
$service
;
}
/**
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
private
function
getConfig
(
ContainerInterface
$container
):
array
{
/** @var array $appConfig */
$appConfig
=
$container
->
get
(
'Config'
);
$config
=
$appConfig
[
'unicaen-dbfakator'
]
??
[];
if
(
$config
)
{
return
[];
}
Assert
::
isArray
(
$config
,
"La config du module doit être un tableau"
);
Assert
::
keyExists
(
$config
,
$k
=
'entities'
,
"La config du module doit posséder la clé '
$k
'"
);
Assert
::
keyExists
(
$config
,
$k
=
'output'
,
"La config du module doit posséder la clé '
$k
'"
);
return
$config
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment