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
a327bfe3
Commit
a327bfe3
authored
Jun 11, 2018
by
Mat
Browse files
readAction pour les 2 entités Info et Lettre
parent
b2dd199c
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/InfoAPIController.php
View file @
a327bfe3
...
...
@@ -2,7 +2,39 @@
namespace
APIBundle\Controller
;
use
Symfony\Component\HttpFoundation\Request
;
class
InfoAPIController
extends
MasterAPIController
{
public
function
createAction
(
Request
$request
)
{
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public
function
readAction
()
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$infos
=
$em
->
getRepository
(
'PotageBundle:Info'
)
->
findAllForAPIRead
();
return
$this
->
api
(
$infos
);
}
public
function
readOneAction
(
$id
)
{
}
public
function
updateAction
(
Request
$request
,
$id
)
{
}
public
function
deleteAction
(
$id
)
{
}
}
src/APIBundle/Controller/LettreAPIController.php
View file @
a327bfe3
...
...
@@ -2,6 +2,39 @@
namespace
APIBundle\Controller
;
use
Symfony\Component\HttpFoundation\Request
;
class
LettreAPIController
extends
MasterAPIController
{
public
function
createAction
(
Request
$request
)
{
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public
function
readAction
()
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$lettres
=
$em
->
getRepository
(
'PotageBundle:Lettre'
)
->
findAllForAPIRead
();
return
$this
->
api
(
$lettres
);
}
public
function
readOneAction
(
$id
)
{
}
public
function
updateAction
(
Request
$request
,
$id
)
{
}
public
function
deleteAction
(
$id
)
{
}
}
src/APIBundle/Resources/config/routing.yml
View file @
a327bfe3
...
...
@@ -114,3 +114,20 @@ api_offre_legumes_read:
defaults
:
_controller
:
APIBundle:OffreLegumesAPI:read
methods
:
[
GET
]
## CRUD LettreAPI
api_lettre_read
:
path
:
/lettres
defaults
:
_controller
:
APIBundle:LettreAPI:read
methods
:
[
GET
]
## CRUD InfoAPI
api_info_read
:
path
:
/infos
defaults
:
_controller
:
APIBundle:InfoAPI:read
methods
:
[
GET
]
src/PotageBundle/Repository/InfoRepository.php
View file @
a327bfe3
...
...
@@ -10,4 +10,16 @@ namespace PotageBundle\Repository;
*/
class
InfoRepository
extends
\
Doctrine\ORM\EntityRepository
{
/**
* @return array Info
*/
public
function
findAllForAPIRead
()
{
$qb
=
$this
->
createQueryBuilder
(
'i'
)
->
orderBy
(
'i.id'
,
'DESC'
);
return
$qb
->
getQuery
()
->
getResult
();
}
}
src/PotageBundle/Repository/LettreRepository.php
View file @
a327bfe3
...
...
@@ -10,4 +10,14 @@ namespace PotageBundle\Repository;
*/
class
LettreRepository
extends
\
Doctrine\ORM\EntityRepository
{
/**
* @return array Lettre
*/
public
function
findAllForAPIRead
()
{
$qb
=
$this
->
createQueryBuilder
(
'l'
)
->
orderBy
(
'l.id'
,
'DESC'
);
return
$qb
->
getQuery
()
->
getResult
();
}
}
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