Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jehba
ddec-info-ng
Commits
302d0546
Commit
302d0546
authored
May 28, 2019
by
Baudouin Feildel
Browse files
Add error & warning in ImportLogger
parent
0cbecd3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Service/Importer/IImportLogger.php
View file @
302d0546
...
...
@@ -78,4 +78,36 @@ interface IImportLogger
* @return int
*/
public
function
getUpdatedGroupsCount
():
int
;
/**
* Get the number of reported errors
* @return int
*/
public
function
getErrorsCount
():
int
;
/**
* Get the number of reported warnings
* @return int
*/
public
function
getWarningsCount
():
int
;
/**
* Get the reported errors
* Each element of the array contains the following elements:
* - line_number an integer
* - line an array
* - message a string
* @return array
*/
public
function
getErrors
():
array
;
/**
* Get the reported warnings
* Each element of the array contains the following elements:
* - line_number an integer
* - line an array
* - message a string
* @return array
*/
public
function
getWarnings
():
array
;
}
\ No newline at end of file
src/Service/Importer/ImportLogger.php
View file @
302d0546
...
...
@@ -19,6 +19,10 @@ class ImportLogger implements IImportLogger
private
$updatedGroups
=
[];
private
$errors
=
[];
private
$warnings
=
[];
private
$logger
;
public
function
__construct
(
LoggerInterface
$logger
)
{
...
...
@@ -137,6 +141,22 @@ class ImportLogger implements IImportLogger
}
}
public
function
reportError
(
int
$line_number
,
array
$line
,
string
$message
)
{
$this
->
errors
[]
=
[
'line_number'
=>
$line_number
,
'line'
=>
$line
,
'message'
=>
$message
,
];
}
public
function
reportWarning
(
int
$line_number
,
array
$line
,
string
$message
)
{
$this
->
warnings
[]
=
[
'line_number'
=>
$line_number
,
'line'
=>
$line
,
'message'
=>
$message
,
];
}
/**
* Get the list of created users during the import
* @return User[]
...
...
@@ -224,4 +244,20 @@ class ImportLogger implements IImportLogger
public
function
getUpdatedGroupsCount
():
int
{
return
count
(
$this
->
updatedGroups
);
}
public
function
getErrorsCount
():
int
{
return
count
(
$this
->
errors
);
}
public
function
getWarningsCount
():
int
{
return
count
(
$this
->
warnings
);
}
public
function
getErrors
():
array
{
return
$this
->
errors
;
}
public
function
getWarnings
():
array
{
return
$this
->
warnings
;
}
}
\ No newline at end of file
templates/admin/user_and_groups_import_result.html.twig
View file @
302d0546
...
...
@@ -17,6 +17,8 @@
<h2>
Vue d'ensemble
</h2>
<ul>
<li>
Nombre d'erreurs :
{{
importLogger.errorsCount
}}
</li>
<li>
Nombre d'avertissements :
{{
importLogger.warningsCount
}}
</li>
<li>
Nombre d'utilisateurs créés
:
{{
importLogger.createdUsersCount
}}
</li>
<li>
Nombre d'utilisateurs mis à jour
:
{{
importLogger.updatedUsersCount
}}
</li>
<li>
Nombre de groupes créés
:
{{
importLogger.createdGroupsCount
}}
</li>
...
...
@@ -25,6 +27,24 @@
<h2>
Détails
</h2>
<h3>
Erreurs
</h3>
<ul>
{%
for
e
in
importLogger.errors
%}
<li>
Ligne
{{
e.line_number
}}
:
{{
e.message
}}
</li>
{%
else
%}
<li><i>
Aucune erreur
</i></li>
{%
endfor
%}
</ul>
<h3>
Avertissements
</h3>
<ul>
{%
for
w
in
importLogger.warnings
%}
<li>
Ligne
{{
w.line_number
}}
:
{{
w.message
}}
</li>
{%
else
%}
<li><i>
Aucun avertissement
</i></li>
{%
endfor
%}
</ul>
<h3>
Utilisateurs
</h3>
<h4>
Créés
</h4>
<ul>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment