From 7046d986194f0a233b473665f63e82eab281073e Mon Sep 17 00:00:00 2001 From: Maximilien Richer Date: Wed, 20 Jan 2016 22:28:03 +0100 Subject: [PATCH] Add Sonata management for managers --- .../TournamentBundle/Admin/ManagerAdmin.php | 50 +++++++++++++++++++ .../TournamentBundle/Admin/PlayerAdmin.php | 1 + .../TournamentBundle/Admin/TeamAdmin.php | 1 + .../Resources/config/services.yml | 11 ++++ 4 files changed, 63 insertions(+) create mode 100644 src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php diff --git a/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php b/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php new file mode 100644 index 00000000..6da5f877 --- /dev/null +++ b/src/InsaLan/TournamentBundle/Admin/ManagerAdmin.php @@ -0,0 +1,50 @@ +add('user') + ->add('gameName') + ->add('tournament') + ->add('participant') + ->add('paymentDone', null, array('required'=>false)) + ->add('arrived', null, array('required'=>false)) + ; + } + + // Fields to be shown on filter forms + protected function configureDatagridFilters(DatagridMapper $datagridMapper) + { + $datagridMapper + ->add('gameName') + ->add('user.username') + ->add('user.email') + ->add('tournament') + ->add('arrived') + ; + } + + // Fields to be shown on lists + protected function configureListFields(ListMapper $listMapper) + { + $listMapper + ->addIdentifier('user.username') + ->addIdentifier('gameName') + ->add('tournament') + ->add('user.email') + ->add('paymentDone') + ->add('arrived') + ; + } + +} diff --git a/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php b/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php index 76f6e22f..2b5d0ee0 100644 --- a/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php +++ b/src/InsaLan/TournamentBundle/Admin/PlayerAdmin.php @@ -15,6 +15,7 @@ protected function configureFormFields(FormMapper $formMapper) $formMapper ->add('user') ->add('team') + ->add('manager') ->add('gameName') ->add('gameValidated', null, array('required'=>false)) ->add('gameAvatar') diff --git a/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php b/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php index 4b92aaf0..c904d75d 100644 --- a/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php +++ b/src/InsaLan/TournamentBundle/Admin/TeamAdmin.php @@ -19,6 +19,7 @@ protected function configureFormFields(FormMapper $formMapper) ->add('name') ->add('tournament') ->add('captain') + ->add('manager') ->add('validated', 'choice', array( 'required' => true, 'choices' => array( diff --git a/src/InsaLan/TournamentBundle/Resources/config/services.yml b/src/InsaLan/TournamentBundle/Resources/config/services.yml index 504ef260..b1924b1a 100644 --- a/src/InsaLan/TournamentBundle/Resources/config/services.yml +++ b/src/InsaLan/TournamentBundle/Resources/config/services.yml @@ -43,6 +43,17 @@ services: calls: - [ setTranslationDomain, [InsaLanTournamentBundle]] + sonata.admin.tournament.manager: + class: InsaLan\TournamentBundle\Admin\ManagerAdmin + tags: + - { name: sonata.admin, manager_type: orm, group: "Tournois", label: "Manager" } + arguments: + - ~ + - InsaLan\TournamentBundle\Entity\Manager + - ~ + calls: + - [ setTranslationDomain, [InsaLanTournamentBundle]] + sonata.admin.tournament.team: class: InsaLan\TournamentBundle\Admin\TeamAdmin tags: