forked from jdewit/GeneratorBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore.php
27 lines (25 loc) · 973 Bytes
/
restore.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* Restore one {{ entity | camelCaseToTitle | lower }}.
*
* @Route("/restore/{id}", name="{{ bundleAlias }}_{{ entityCC }}_restore", defaults={"id" = false})
* @method("post")
*/
public function restoreAction($id)
{
${{ entityCC }} = $this->container->get('{{ bundleAlias }}.{{ entityCC }}_manager')->find($id);
$process = $this->container->get('{{ bundleAlias }}.{{ entityCC }}_manager')->restore(${{ entityCC }});
if ($process === true) {
$response = new Response('{
"status": "OK",
"notice": "{{ entityTitle }} restored.",
"data": $id
}');
} else {
$response = new Response('{
"status": "OK",
"notice": "Unable to restore {{ entityTitle }}."
}');
}
$response->headers->set('Content-Type', 'application/json');
return $response;
}