[11/06/2024] Les premières modifs + installation de quelques modules indispensables
This commit is contained in:
197
domokits/local/modules/TheliaLibrary/Controller/Admin/ImageController.php
Executable file
197
domokits/local/modules/TheliaLibrary/Controller/Admin/ImageController.php
Executable file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Thelia package.
|
||||
* http://www.thelia.net
|
||||
*
|
||||
* (c) OpenStudio <info@thelia.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace TheliaLibrary\Controller\Admin;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Controller\Admin\BaseAdminOpenApiController;
|
||||
use OpenApi\Model\Api\ModelFactory;
|
||||
use OpenApi\Service\OpenApiService;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use TheliaLibrary\Service\LibraryImageService;
|
||||
|
||||
/**
|
||||
* @Route("/open_api/library/image", name="library_image")
|
||||
*/
|
||||
class ImageController extends BaseAdminOpenApiController
|
||||
{
|
||||
/**
|
||||
* @Route("", name="_create", methods="POST")
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/library/image",
|
||||
* tags={ "Library image"},
|
||||
* summary="Create a new image",
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\MediaType(
|
||||
* mediaType="multipart/form-data",
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="locale",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="image",
|
||||
* type="string",
|
||||
* format="binary"
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryImage")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function createImage(
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryImageService $libraryImageService
|
||||
) {
|
||||
$locale = $this->findLocale($request);
|
||||
|
||||
$image = $libraryImageService->createImage(
|
||||
$request->files->get('image'),
|
||||
$request->request->get('title'),
|
||||
$locale
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryImage', $image, $locale));
|
||||
}
|
||||
|
||||
// Method POST because patch doesn't work with multipart/form-data
|
||||
|
||||
/**
|
||||
* @Route("/{imageId}", name="_update", methods="POST", requirements={"imageId"="\d+"})
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/library/image/{imageId}",
|
||||
* tags={ "Library image"},
|
||||
* summary="Update an image",
|
||||
* @OA\Parameter(
|
||||
* name="imageId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\MediaType(
|
||||
* mediaType="multipart/form-data",
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="locale",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="image",
|
||||
* type="string",
|
||||
* format="binary"
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryImage")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function updateImage(
|
||||
$imageId,
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryImageService $libraryImageService
|
||||
) {
|
||||
$locale = $this->findLocale($request);
|
||||
$image = $libraryImageService->updateImage(
|
||||
$imageId,
|
||||
$request->files->get('image'),
|
||||
$request->request->get('title'),
|
||||
$locale
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryImage', $image, $locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{imageId}", name="_delete", methods="DELETE", requirements={"imageId"="\d+"})
|
||||
*
|
||||
* @OA\Delete(
|
||||
* path="/library/image/{imageId}",
|
||||
* tags={ "Library image"},
|
||||
* summary="Delete an image",
|
||||
* @OA\Parameter(
|
||||
* name="imageId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="204",
|
||||
* description="Success"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteImage(
|
||||
$imageId,
|
||||
LibraryImageService $libraryImageService
|
||||
) {
|
||||
$libraryImageService->deleteImage($imageId);
|
||||
|
||||
return new JsonResponse('Success', 204);
|
||||
}
|
||||
|
||||
protected function findLocale(Request $request)
|
||||
{
|
||||
$locale = $request->get('locale');
|
||||
|
||||
if (null == $locale) {
|
||||
$locale = $request->getSession()->getAdminEditionLang()->getLocale();
|
||||
}
|
||||
|
||||
return $locale;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Thelia package.
|
||||
* http://www.thelia.net
|
||||
*
|
||||
* (c) OpenStudio <info@thelia.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace TheliaLibrary\Controller\Admin;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Controller\Admin\BaseAdminOpenApiController;
|
||||
use OpenApi\Model\Api\ModelFactory;
|
||||
use OpenApi\Service\OpenApiService;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use TheliaLibrary\Model\LibraryImageTag;
|
||||
use TheliaLibrary\Model\LibraryTagQuery;
|
||||
use TheliaLibrary\Service\LibraryImageTagService;
|
||||
|
||||
/**
|
||||
* @Route("/open_api/library/image_tag", name="library_image_tag")
|
||||
*/
|
||||
class ImageTagController extends BaseAdminOpenApiController
|
||||
{
|
||||
/**
|
||||
* @Route("", name="_associate", methods="POST")
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/library/image_tag",
|
||||
* tags={ "Library tag"},
|
||||
* summary="Associate a tag to an image",
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="imageId",
|
||||
* type="integer",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="tagId",
|
||||
* type="integer",
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryImageTag")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function createAssociation(
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryImageTagService $libraryImageTagService
|
||||
) {
|
||||
$data = json_decode($request->getContent(), true);
|
||||
/** @var LibraryImageTag $openApiLibraryImageTag */
|
||||
$openApiLibraryImageTag = $modelFactory->buildModel('LibraryImageTag', $data);
|
||||
$openApiLibraryImageTag->validate(self::GROUP_UPDATE);
|
||||
|
||||
$image = $libraryImageTagService->associateImage(
|
||||
$openApiLibraryImageTag->getImageId(),
|
||||
$openApiLibraryImageTag->getTagId(),
|
||||
);
|
||||
|
||||
$query = LibraryTagQuery::create();
|
||||
$tag = $query->findOneById($openApiLibraryImageTag->getTagId());
|
||||
|
||||
return OpenApiService::jsonResponse(['imageTag' => $modelFactory->buildModel('LibraryImageTag', $image), 'tag' => $modelFactory->buildModel('LibraryTag', $tag)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{imageTagId}", name="_delete_association", methods="DELETE", requirements={"imageTagId"="\d+"})
|
||||
*
|
||||
* @OA\Delete(
|
||||
* path="/library/image_tag/{imageTagId}",
|
||||
* tags={ "Library tag"},
|
||||
* summary="Delete an association",
|
||||
* @OA\Parameter(
|
||||
* name="imageTagId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="204",
|
||||
* description="Success"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteAssociation(
|
||||
$imageTagId,
|
||||
LibraryImageTagService $libraryImageTagService
|
||||
) {
|
||||
$libraryImageTagService->deleteImageAssociation($imageTagId);
|
||||
|
||||
return new JsonResponse('Success', 204);
|
||||
}
|
||||
}
|
||||
198
domokits/local/modules/TheliaLibrary/Controller/Admin/ItemImageController.php
Executable file
198
domokits/local/modules/TheliaLibrary/Controller/Admin/ItemImageController.php
Executable file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Thelia package.
|
||||
* http://www.thelia.net
|
||||
*
|
||||
* (c) OpenStudio <info@thelia.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace TheliaLibrary\Controller\Admin;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Controller\Admin\BaseAdminOpenApiController;
|
||||
use OpenApi\Model\Api\ModelFactory;
|
||||
use OpenApi\Service\OpenApiService;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use TheliaLibrary\Model\Api\LibraryItemImage;
|
||||
use TheliaLibrary\Service\LibraryItemImageService;
|
||||
|
||||
/**
|
||||
* @Route("/open_api/library/item_image", name="library_item_image")
|
||||
*/
|
||||
class ItemImageController extends BaseAdminOpenApiController
|
||||
{
|
||||
/**
|
||||
* @Route("", name="_associate", methods="POST")
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/library/item_image",
|
||||
* tags={ "Library image"},
|
||||
* summary="Associate an image to an item",
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="imageId",
|
||||
* type="integer",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="itemType",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="itemId",
|
||||
* type="integer",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="code",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="visible",
|
||||
* type="boolean",
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryItemImage")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function createAssociation(
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryItemImageService $libraryItemImageService
|
||||
) {
|
||||
$data = json_decode($request->getContent(), true);
|
||||
/** @var LibraryItemImage $openApiLibraryItemImage */
|
||||
$openApiLibraryItemImage = $modelFactory->buildModel('LibraryItemImage', $data);
|
||||
$openApiLibraryItemImage->validate(self::GROUP_UPDATE);
|
||||
|
||||
$image = $libraryItemImageService->associateImage(
|
||||
$openApiLibraryItemImage->getImageId(),
|
||||
$openApiLibraryItemImage->getItemType(),
|
||||
$openApiLibraryItemImage->getItemId(),
|
||||
$openApiLibraryItemImage->getCode(),
|
||||
$openApiLibraryItemImage->isVisible(),
|
||||
$openApiLibraryItemImage->getPosition()
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryItemImage', $image));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{itemImageId}", name="_update_association", methods="PATCH", requirements={"itemImageId"="\d+"})
|
||||
*
|
||||
* @OA\Patch(
|
||||
* path="/library/item_image/{itemImageId}",
|
||||
* tags={ "Library image"},
|
||||
* summary="Update an association",
|
||||
* @OA\Parameter(
|
||||
* name="itemImageId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="visible",
|
||||
* type="boolean",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="code",
|
||||
* type="string",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="position",
|
||||
* type="integer",
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="positionMovement",
|
||||
* type="string",
|
||||
* enum={"up", "down"}
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryItemImage")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function updateAssociation(
|
||||
$itemImageId,
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryItemImageService $libraryItemImageService
|
||||
) {
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
$image = $libraryItemImageService->updateImageAssociation(
|
||||
$itemImageId,
|
||||
$data['code'] ?? null,
|
||||
$data['visible'] ?? null,
|
||||
$data['position'] ?? null,
|
||||
$data['positionMovement'] ?? null
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryItemImage', $image));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{itemImageId}", name="_delete_association", methods="DELETE", requirements={"itemImageId"="\d+"})
|
||||
*
|
||||
* @OA\Delete(
|
||||
* path="/library/item_image/{itemImageId}",
|
||||
* tags={ "Library image"},
|
||||
* summary="Delete an association",
|
||||
* @OA\Parameter(
|
||||
* name="itemImageId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="204",
|
||||
* description="Success"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteAssociation(
|
||||
$itemImageId,
|
||||
LibraryItemImageService $libraryItemImageService
|
||||
) {
|
||||
$libraryItemImageService->deleteImageAssociation($itemImageId);
|
||||
|
||||
return new JsonResponse('Success', 204);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Thelia package.
|
||||
* http://www.thelia.net
|
||||
*
|
||||
* (c) OpenStudio <info@thelia.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace TheliaLibrary\Controller\Admin;
|
||||
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Controller\Admin\BaseAdminOpenApiController;
|
||||
use OpenApi\Model\Api\ModelFactory;
|
||||
use OpenApi\Service\OpenApiService;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Thelia\Core\HttpFoundation\JsonResponse;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use TheliaLibrary\Model\Base\LibraryTagQuery;
|
||||
use TheliaLibrary\Model\LibraryTag;
|
||||
use TheliaLibrary\Service\LibraryTagService;
|
||||
|
||||
/**
|
||||
* @Route("/open_api/library/tag", name="library_tag")
|
||||
*/
|
||||
class TagController extends BaseAdminOpenApiController
|
||||
{
|
||||
/**
|
||||
* @Route("", name="_view", methods="GET")
|
||||
* @OA\Get(
|
||||
* path="/library/tag",
|
||||
* tags={"Library tag"},
|
||||
* summary="Get tags",
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryTag")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function getTags(Request $request, ModelFactory $modelFactory)
|
||||
{
|
||||
$query = LibraryTagQuery::create();
|
||||
$locale = $this->findLocale($request);
|
||||
|
||||
return OpenApiService::jsonResponse(array_map(
|
||||
function (LibraryTag $tag) use ($modelFactory, $locale) {
|
||||
/** @var \TheliaLibrary\Model\Api\LibraryTag $tagModel */
|
||||
$tagModel = $modelFactory->buildModel('LibraryTag', $tag, $locale);
|
||||
|
||||
return $tagModel;
|
||||
},
|
||||
iterator_to_array($query->find())
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("", name="_create", methods="POST")
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/library/tag",
|
||||
* tags={ "Library tag"},
|
||||
* summary="Create a new tag",
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="colorCode",
|
||||
* default="#000000",
|
||||
* type="string"
|
||||
* ),
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryTag")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function createTag(
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryTagService $libraryTagService
|
||||
) {
|
||||
$locale = $this->findLocale($request);
|
||||
|
||||
$tag = $libraryTagService->createTag(
|
||||
$request->request->get('title'),
|
||||
$request->request->get('colorCode'),
|
||||
$locale
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryTag', $tag, $locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{tagId}", name="_update", methods="POST", requirements={"tagId"="\d+"})
|
||||
* @OA\Post(
|
||||
* path="/library/tag/{tagId}",
|
||||
* tags={ "Library tag"},
|
||||
* summary="update a tag",
|
||||
* @OA\Parameter(
|
||||
* name="tagId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="title",
|
||||
* type="string"
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="colorCode",
|
||||
* default="#000000",
|
||||
* type="string"
|
||||
* ),
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Success",
|
||||
* @OA\JsonContent(ref="#/components/schemas/LibraryTag")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function updateTag(
|
||||
$tagId,
|
||||
Request $request,
|
||||
ModelFactory $modelFactory,
|
||||
LibraryTagService $libraryTagService
|
||||
) {
|
||||
$locale = $this->findLocale($request);
|
||||
$tag = $libraryTagService->updateTag(
|
||||
$tagId,
|
||||
$request->request->get('title'),
|
||||
$request->request->get('colorCode'),
|
||||
$locale
|
||||
);
|
||||
|
||||
return OpenApiService::jsonResponse($modelFactory->buildModel('LibraryTag', $tag, $locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{tagId}", name="_delete", methods="DELETE", requirements={"tagId"="\d+"})
|
||||
*
|
||||
* @OA\Delete(
|
||||
* path="/library/tag/{tagId}",
|
||||
* tags={ "Library tag"},
|
||||
* summary="Delete a tag",
|
||||
* @OA\Parameter(
|
||||
* name="tagId",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="integer"
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="204",
|
||||
* description="Success"
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="400",
|
||||
* description="Bad request",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error")
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function deleteTag(
|
||||
$tagId,
|
||||
LibraryTagService $libraryTagService
|
||||
) {
|
||||
$libraryTagService->deleteTag($tagId);
|
||||
|
||||
return new JsonResponse('Success', 204);
|
||||
}
|
||||
|
||||
protected function findLocale(Request $request)
|
||||
{
|
||||
$locale = $request->get('locale');
|
||||
|
||||
if (null == $locale) {
|
||||
$locale = $request->getSession()->getAdminEditionLang()->getLocale();
|
||||
}
|
||||
|
||||
return $locale;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user