Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-mlc
kohinos
Commits
ed1727e0
Commit
ed1727e0
authored
Sep 25, 2020
by
Mathieu Poisbeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#181: si erreur fatal/technique lors de l'import => l'affiche proprement à l'utilisateur
parent
28abaf87
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
ImportController.php
src/Controller/ImportController.php
+8
-3
import_error.html.twig
templates/admin/import_error.html.twig
+25
-0
No files found.
src/Controller/ImportController.php
View file @
ed1727e0
...
@@ -82,9 +82,6 @@ class ImportController extends CRUDController
...
@@ -82,9 +82,6 @@ class ImportController extends CRUDController
$this
->
sendemail
=
false
;
$this
->
sendemail
=
false
;
}
}
/**
* @TODO: manage the case of a fatal error (so catch the exception, and display a nice message)!
*/
public
function
createAction
()
public
function
createAction
()
{
{
$this
->
siege
=
$this
->
em
->
getRepository
(
Siege
::
class
)
->
findOneById
(
1
);
$this
->
siege
=
$this
->
em
->
getRepository
(
Siege
::
class
)
->
findOneById
(
1
);
...
@@ -104,6 +101,7 @@ class ImportController extends CRUDController
...
@@ -104,6 +101,7 @@ class ImportController extends CRUDController
$this
->
em
->
flush
();
$this
->
em
->
flush
();
$idimport
=
$import
->
getId
();
$idimport
=
$import
->
getId
();
try
{
$this
->
importFromCSV
(
$type
,
$media
);
$this
->
importFromCSV
(
$type
,
$media
);
$import
=
$this
->
em
->
getRepository
(
Import
::
class
)
->
findOneById
(
$idimport
);
$import
=
$this
->
em
->
getRepository
(
Import
::
class
)
->
findOneById
(
$idimport
);
...
@@ -129,7 +127,14 @@ class ImportController extends CRUDController
...
@@ -129,7 +127,14 @@ class ImportController extends CRUDController
);
);
}
}
return
$this
->
redirect
(
$this
->
admin
->
generateUrl
(
'show'
,
array
(
'id'
=>
$import
->
getId
())));
return
$this
->
redirect
(
$this
->
admin
->
generateUrl
(
'show'
,
array
(
'id'
=>
$import
->
getId
())));
}
catch
(
\Exception
$e
)
{
return
$this
->
renderWithExtraParams
(
'admin/import_error.html.twig'
,
[
'action'
=>
'list'
,
'error'
=>
$e
->
getMessage
(),
]);
}
}
}
return
$this
->
renderWithExtraParams
(
'admin/import.html.twig'
,
array
(
return
$this
->
renderWithExtraParams
(
'admin/import.html.twig'
,
array
(
'action'
=>
'list'
,
'action'
=>
'list'
,
'form'
=>
$form
->
createView
(),
'form'
=>
$form
->
createView
(),
...
...
templates/admin/import_error.html.twig
0 → 100644
View file @
ed1727e0
{%
extends
base_template
%}
{%
import
_self
as
macros
%}
{%
-
block
tab_menu
-
%}
{{
knp_menu_render
(
admin.sidemenu
(
action
),
{
'currentClass'
:
'active'
,
'template'
:
get_global_template
(
'tab_menu_template'
)
}
,
'twig'
)
}}
{%
-
endblock
-
%}
{%
block
title
%}
{{
'Import de données : erreur !'
|
trans
}}
{%
endblock
%}
{%
block
navbar_title
%}
{{
block
(
'title'
)
}}
{%
endblock
%}
{%
block
content
%}
<div
class=
"px-3"
>
<h3>
Erreur lors de l'importation !
</h3>
<p><strong>
Message à transmettre à l'équipe technique :
</strong>
{{
error
}}
</p>
</div>
{%
endblock
%}
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