Skip to content
GitLab
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
b0fc54b8
Commit
b0fc54b8
authored
Jul 04, 2018
by
Mat
Browse files
Merge branch 'test_query_dump' into dev
parents
fb7c6151
ea2e9453
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/MasterAPIController.php
View file @
b0fc54b8
...
...
@@ -2,6 +2,7 @@
namespace
APIBundle\Controller
;
use
JMS\Serializer\SerializationContext
;
use
PotageBundle\Controller\MasterController
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
...
...
@@ -17,7 +18,7 @@ abstract class MasterAPIController extends MasterController
protected
function
api
(
$data
,
$status
=
200
)
{
$serializer
=
$this
->
get
(
'jms_serializer'
);
$serialized
=
$serializer
->
serialize
(
$data
,
'json'
);
$serialized
=
$serializer
->
serialize
(
$data
,
'json'
,
SerializationContext
::
create
()
->
enableMaxDepthChecks
()
);
// if ($data instanceof Form) {
// $status = 400;
...
...
src/PotageBundle/Controller/UtilisateurController.php
View file @
b0fc54b8
...
...
@@ -3,6 +3,7 @@
namespace
PotageBundle\Controller
;
use
APIBundle\Form\UtilisateurAPIType
;
use
Symfony\Component\HttpFoundation\Request
;
class
UtilisateurController
extends
MasterController
{
...
...
@@ -17,4 +18,30 @@ class UtilisateurController extends MasterController
'formUtilisateur'
=>
$form
->
createView
()
));
}
/**
* TESTS
*
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public
function
testReadAction
(
Request
$request
)
{
// defaults
$paginate
=
(
$request
->
query
->
get
(
'step'
)
!==
null
)
?
$request
->
query
->
get
(
'step'
)
:
10
;
$start
=
(
$request
->
query
->
get
(
'page'
)
!==
null
)
?
$request
->
query
->
get
(
'page'
)
:
1
;
$column
=
(
$request
->
query
->
get
(
'column'
)
!==
null
)
?
$request
->
query
->
get
(
'column'
)
:
'id'
;
$order
=
(
$request
->
query
->
get
(
'order'
)
!==
null
)
?
$request
->
query
->
get
(
'order'
)
:
'ASC'
;
$utilisateurs
=
$this
->
getDoctrine
()
->
getManager
()
->
getRepository
(
'PotageBundle:Utilisateur'
)
->
findAllForAPIReadPaginate
(
$paginate
,
$start
,
$column
,
$order
);
dump
(
$utilisateurs
);
return
$this
->
render
(
'@Potage/Default/test.html.twig'
,
array
(
'utilisateurs'
=>
$utilisateurs
));
}
}
src/PotageBundle/Entity/Info.php
View file @
b0fc54b8
...
...
@@ -2,6 +2,7 @@
namespace
PotageBundle\Entity
;
use
JMS\Serializer\Annotation\MaxDepth
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\Common\Collections\Collection
;
use
Doctrine\ORM\Mapping
as
ORM
;
...
...
@@ -27,6 +28,7 @@ class Info
/**
* @var int
* @ORM\ManyToMany(targetEntity="PotageBundle\Entity\Lettre", mappedBy="infos")
* @MaxDepth(3)
*/
private
$lettres
;
...
...
src/PotageBundle/Entity/Lettre.php
View file @
b0fc54b8
...
...
@@ -2,6 +2,7 @@
namespace
PotageBundle\Entity
;
use
JMS\Serializer\Annotation\MaxDepth
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\ORM\Mapping
as
ORM
;
...
...
@@ -27,6 +28,7 @@ class Lettre
* @var int
* @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Offre", inversedBy="lettres")
* @ORM\JoinColumn(name="id_offre", nullable=false)
* @MaxDepth(2)
*/
private
$offre
;
...
...
@@ -44,6 +46,7 @@ class Lettre
* @var int
* @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Groupe", inversedBy="lettres")
* @ORM\JoinColumn(name="id_groupe", nullable=false)
* @MaxDepth(2)
*/
private
$groupe
;
...
...
src/PotageBundle/Entity/Offre.php
View file @
b0fc54b8
...
...
@@ -2,6 +2,7 @@
namespace
PotageBundle\Entity
;
use
JMS\Serializer\Annotation\MaxDepth
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\ORM\Mapping
as
ORM
;
...
...
@@ -27,12 +28,14 @@ class Offre
/**
* @var OffreLegumes[]
* @ORM\OneToMany(targetEntity="PotageBundle\Entity\OffreLegumes", mappedBy="offre")
* @MaxDepth(2)
*/
private
$offreLegumes
;
/**
* @var Lettre[]
* @ORM\OneToMany(targetEntity="PotageBundle\Entity\Lettre", mappedBy="offre")
* @MaxDepth(2)
*/
private
$lettres
;
...
...
src/PotageBundle/Entity/Utilisateur.php
View file @
b0fc54b8
...
...
@@ -2,6 +2,7 @@
namespace
PotageBundle\Entity
;
use
JMS\Serializer\Annotation\MaxDepth
;
use
Symfony\Component\Validator\Constraints
as
Assert
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\Common\Collections\Collection
;
...
...
@@ -39,6 +40,7 @@ class Utilisateur
* joinColumns={@ORM\JoinColumn(name="id_groupe", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="id_utilisateur", referencedColumnName="id")}
* )
* @MaxDepth(3)
*/
private
$groupes
;
...
...
src/PotageBundle/Repository/UtilisateurRepository.php
View file @
b0fc54b8
...
...
@@ -23,11 +23,6 @@ class UtilisateurRepository extends \Doctrine\ORM\EntityRepository
public
function
findAllForAPIReadPaginate
(
$paginate
,
$start
,
$column
=
null
,
$order
=
null
)
{
$qb
=
$this
->
createQueryBuilder
(
'u'
)
//->select('u.id', 'u.nom', 'u.prenom', 'u.email', 'u.createdAt', 'u.updatedAt')
//->leftJoin('u.groupes', 'g')
//->addSelect('g.id gid', 'g.nom gNom')
//->leftJoin('u.user', 'fu')
//->addSelect('fu.id fuid', 'fu.email fuemail', 'fu.username funame')
->
setMaxResults
(
$paginate
)
->
setFirstResult
((
$start
-
1
)
*
$paginate
);
if
(
$column
!==
null
)
{
...
...
src/PotageBundle/Resources/config/routing.yml
View file @
b0fc54b8
...
...
@@ -61,3 +61,10 @@ potage_utilisateur_ajax_display:
defaults
:
_controller
:
PotageBundle:Utilisateur:ajaxDisplay
methods
:
[
GET
]
potage_utilisateur_test
:
path
:
/admin/utilisateurs/tests
defaults
:
_controller
:
PotageBundle:Utilisateur:testRead
methods
:
[
GET
]
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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