Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
technobel.sf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
technobel.sf
Commits
425811c2
Commit
425811c2
authored
Jul 11, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c'est mieux de gérer la route delete sans le try..catch
parent
4519273f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
0ne/orig/ajax/index4.html
0ne/orig/ajax/index4.html
+7
-8
src/Api2Bundle/Controller/BrasserieController.php
src/Api2Bundle/Controller/BrasserieController.php
+8
-18
No files found.
0ne/orig/ajax/index4.html
View file @
425811c2
...
...
@@ -23,6 +23,7 @@ $(document).ready(function()
{
let
targetedId
;
// supprime une brasserie
$
(
'
#delete
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
...
...
@@ -30,14 +31,12 @@ $(document).ready(function()
url
:
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie/
"
+
targetedId
,
dataType
:
'
JSON
'
,
method
:
'
DELETE
'
,
success
:
function
(
data
)
{
if
(
data
)
{
alert
(
'
success
'
);
$
(
"
li[data-target=
"
+
targetedId
+
"
]
"
).
remove
();
targetedId
=
undefined
;
}
else
{
alert
(
'
error
'
);
}
success
:
function
(
data
)
{
alert
(
'
success
'
);
$
(
"
li[data-target=
"
+
data
.
id
+
"
]
"
).
remove
();
targetedId
=
undefined
;
},
error
:
(
xhr
)
=>
{
console
.
log
(
xhr
);
...
...
src/Api2Bundle/Controller/BrasserieController.php
100755 → 100644
View file @
425811c2
...
...
@@ -99,26 +99,16 @@ class BrasserieController extends FOSRestController
}
/**
* @param
$i
d
* @Rest\Delete(path="/brasserie/{
i
d}")
* @param
Brasserie $brasserieI
d
* @Rest\Delete(path="/brasserie/{
brasserieI
d}")
* @Rest\View()
* @return
bool
* @return
Brasserie
*/
public
function
deleteAction
(
$i
d
)
public
function
deleteAction
(
Brasserie
$brasserieI
d
)
{
try
{
$brasserie
=
$this
->
getDoctrine
()
->
getRepository
(
Brasserie
::
class
)
->
find
(
$id
);
$em
=
$this
->
getDoctrine
()
->
getManager
();
$em
->
remove
(
$brasserie
);
$em
->
flush
();
return
true
;
}
catch
(
\Exception
$exception
)
{
return
false
;
}
$em
=
$this
->
getDoctrine
()
->
getManager
();
$em
->
remove
(
$brasserieId
);
$em
->
flush
();
return
$brasserieId
;
}
}
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