Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mathieu
potage
Commits
d7d6493d
Commit
d7d6493d
authored
Jun 17, 2018
by
Mat
Browse files
évite d'appeler 2x le même repository
parent
4ec5e852
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/LegumeAPIController.php
View file @
d7d6493d
...
...
@@ -214,8 +214,7 @@ class LegumeAPIController extends MasterAPIController
public
function
insertAction
(
Request
$request
,
$id
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$legume
=
$em
->
getRepository
(
'PotageBundle:Legume'
)
->
findOneForAPIRead
(
$id
);
// TODO temporaire, réutilise un repository déjà existant
$legume
=
$em
->
getRepository
(
'PotageBundle:Legume'
)
->
findOneForAPIInsert
(
$id
);
if
(
$legume
===
null
)
{
return
$this
->
api
(
$legume
,
Response
::
HTTP_NOT_FOUND
);
...
...
src/PotageBundle/Repository/LegumeRepository.php
View file @
d7d6493d
...
...
@@ -46,7 +46,20 @@ class LegumeRepository extends \Doctrine\ORM\EntityRepository
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public
function
findOneForAPIInsert
(
$id
)
{
$qb
=
$this
->
createQueryBuilder
(
'l'
)
->
where
(
'l.id = :id'
)
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
/**
* @param $id
* @return mixed
...
...
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