mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Create api endpoint for listing user-group
This commit is contained in:
		| @@ -0,0 +1,16 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| /* | ||||
|  * Chill is a software for social workers | ||||
|  * | ||||
|  * For the full copyright and license information, please view | ||||
|  * the LICENSE file that was distributed with this source code. | ||||
|  */ | ||||
|  | ||||
| namespace Chill\MainBundle\Controller; | ||||
|  | ||||
| use Chill\MainBundle\CRUD\Controller\ApiController; | ||||
|  | ||||
| class UserGroupApiController extends ApiController {} | ||||
| @@ -24,6 +24,7 @@ use Chill\MainBundle\Controller\LocationTypeController; | ||||
| use Chill\MainBundle\Controller\NewsItemController; | ||||
| use Chill\MainBundle\Controller\RegroupmentController; | ||||
| use Chill\MainBundle\Controller\UserController; | ||||
| use Chill\MainBundle\Controller\UserGroupApiController; | ||||
| use Chill\MainBundle\Controller\UserJobApiController; | ||||
| use Chill\MainBundle\Controller\UserJobController; | ||||
| use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface; | ||||
| @@ -59,6 +60,7 @@ use Chill\MainBundle\Entity\LocationType; | ||||
| use Chill\MainBundle\Entity\NewsItem; | ||||
| use Chill\MainBundle\Entity\Regroupment; | ||||
| use Chill\MainBundle\Entity\User; | ||||
| use Chill\MainBundle\Entity\UserGroup; | ||||
| use Chill\MainBundle\Entity\UserJob; | ||||
| use Chill\MainBundle\Form\CenterType; | ||||
| use Chill\MainBundle\Form\CivilityType; | ||||
| @@ -803,6 +805,21 @@ class ChillMainExtension extends Extension implements | ||||
|                         ], | ||||
|                     ], | ||||
|                 ], | ||||
|                 [ | ||||
|                     'class' => UserGroup::class, | ||||
|                     'controller' => UserGroupApiController::class, | ||||
|                     'name' => 'user-group', | ||||
|                     'base_path' => '/api/1.0/main/user-group', | ||||
|                     'base_role' => 'ROLE_USER', | ||||
|                     'actions' => [ | ||||
|                         '_index' => [ | ||||
|                             'methods' => [ | ||||
|                                 Request::METHOD_GET => true, | ||||
|                                 Request::METHOD_HEAD => true, | ||||
|                             ], | ||||
|                         ], | ||||
|                     ], | ||||
|                 ], | ||||
|             ], | ||||
|         ]); | ||||
|     } | ||||
|   | ||||
| @@ -14,17 +14,21 @@ namespace Chill\MainBundle\Entity; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use Doctrine\Common\Collections\Collection; | ||||
| use Doctrine\ORM\Mapping as ORM; | ||||
| use Symfony\Component\Serializer\Annotation as Serializer; | ||||
|  | ||||
| #[ORM\Entity] | ||||
| #[ORM\Table(name: 'chill_main_user_group')] | ||||
| #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['user_group' => UserGroup::class])] | ||||
| class UserGroup | ||||
| { | ||||
|     #[ORM\Id] | ||||
|     #[ORM\GeneratedValue] | ||||
|     #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false)] | ||||
|     #[Serializer\Groups(['read'])] | ||||
|     private ?int $id = null; | ||||
|  | ||||
|     #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])] | ||||
|     #[Serializer\Groups(['read'])] | ||||
|     private array $label = []; | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -908,3 +908,19 @@ paths: | ||||
|                                     $ref: '#/components/schemas/NewsItem' | ||||
|                 403: | ||||
|                     description: "Unauthorized" | ||||
|     /1.0/main/user-group.json: | ||||
|         get: | ||||
|             tags: | ||||
|                 - user-group | ||||
|             summary: Return a list of users-groups | ||||
|             responses: | ||||
|                 200: | ||||
|                     description: "ok" | ||||
|                     content: | ||||
|                         application/json: | ||||
|                             schema: | ||||
|                                 type: array | ||||
|                                 items: | ||||
|                                     $ref: '#/components/schemas/NewsItem' | ||||
|                 403: | ||||
|                     description: "Unauthorized" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user