diff --git a/Config/TheliaMain.sql b/Config/TheliaMain.sql
index 0140cec..fe8435a 100755
--- a/Config/TheliaMain.sql
+++ b/Config/TheliaMain.sql
@@ -12,7 +12,6 @@ DROP TABLE IF EXISTS `library_image`;
CREATE TABLE `library_image`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
- `slug` VARCHAR(255),
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
@@ -28,6 +27,7 @@ CREATE TABLE `library_item_image`
`image_id` INTEGER,
`item_type` VARCHAR(255),
`item_id` INTEGER,
+ `code` VARCHAR(255),
`visible` TINYINT,
`position` INTEGER,
PRIMARY KEY (`id`),
diff --git a/Config/schema.xml b/Config/schema.xml
index ace2116..70a6e59 100755
--- a/Config/schema.xml
+++ b/Config/schema.xml
@@ -5,7 +5,6 @@
-
@@ -18,6 +17,7 @@
+
diff --git a/Controller/Admin/ImageController.php b/Controller/Admin/ImageController.php
index 307a768..959951c 100755
--- a/Controller/Admin/ImageController.php
+++ b/Controller/Admin/ImageController.php
@@ -33,10 +33,6 @@ class ImageController extends BaseAdminOpenApiController
* type="string",
* ),
* @OA\Property(
- * property="slug",
- * type="string",
- * ),
- * @OA\Property(
* property="locale",
* type="string",
* ),
@@ -71,7 +67,6 @@ public function createImage(
$image = $libraryImageService->createImage(
$request->files->get('image'),
$request->request->get('title'),
- $request->request->get('slug'),
$locale
);
@@ -105,10 +100,6 @@ public function createImage(
* type="string",
* ),
* @OA\Property(
- * property="slug",
- * type="string",
- * ),
- * @OA\Property(
* property="locale",
* type="string",
* ),
@@ -144,7 +135,6 @@ public function updateImage(
$imageId,
$request->files->get('image'),
$request->request->get('title'),
- $request->request->get('slug'),
$locale
);
diff --git a/Controller/Admin/ItemImageController.php b/Controller/Admin/ItemImageController.php
index 236e9db..c74e6d6 100755
--- a/Controller/Admin/ItemImageController.php
+++ b/Controller/Admin/ItemImageController.php
@@ -40,6 +40,10 @@ class ItemImageController extends BaseAdminOpenApiController
* type="integer",
* ),
* @OA\Property(
+ * property="code",
+ * type="string",
+ * ),
+ * @OA\Property(
* property="visible",
* type="boolean",
* )
@@ -72,6 +76,7 @@ public function createAssociation(
$openApiLibraryItemImage->getImageId(),
$openApiLibraryItemImage->getItemType(),
$openApiLibraryItemImage->getItemId(),
+ $openApiLibraryItemImage->getCode(),
$openApiLibraryItemImage->isVisible(),
$openApiLibraryItemImage->getPosition()
);
@@ -101,6 +106,10 @@ public function createAssociation(
* property="visible",
* type="boolean",
* ),
+ * @OA\Property(
+ * property="code",
+ * type="string",
+ * ),
* @OA\Property(
* property="position",
* type="integer",
@@ -135,6 +144,7 @@ public function updateAssociation(
$image = $libraryItemImageService->updateImageAssociation(
$itemImageId,
+ $data['code']?? null,
$data['visible']?? null,
$data['position']?? null,
$data['positionMovement']?? null
diff --git a/Controller/Front/ImageController.php b/Controller/Front/ImageController.php
index 2e23ef6..4099fec 100644
--- a/Controller/Front/ImageController.php
+++ b/Controller/Front/ImageController.php
@@ -31,13 +31,6 @@ class ImageController extends BaseFrontOpenApiController
* )
* ),
* @OA\Parameter(
- * name="slug",
- * in="query",
- * @OA\Schema(
- * type="string"
- * )
- * ),
- * @OA\Parameter(
* name="offset",
* in="query",
* @OA\Schema(
@@ -96,10 +89,6 @@ public function getImage(
$imageQuery->filterById($id);
}
- if (null !== $slug = $request->get('slug')) {
- $imageQuery->filterBySlug($slug);
- }
-
if (null !== $limit = $request->get('limit', 20)) {
$imageQuery->limit($limit);
}
diff --git a/Controller/Front/ItemImageController.php b/Controller/Front/ItemImageController.php
index af86bd7..9a8da4c 100644
--- a/Controller/Front/ItemImageController.php
+++ b/Controller/Front/ItemImageController.php
@@ -40,6 +40,13 @@ class ItemImageController extends BaseFrontOpenApiController
* )
* ),
* @OA\Parameter(
+ * name="code",
+ * in="query",
+ * @OA\Schema(
+ * type="string"
+ * )
+ * ),
+ * @OA\Parameter(
* name="offset",
* in="query",
* @OA\Schema(
@@ -85,6 +92,10 @@ public function getItemImage(
$itemImageQuery->filterByItemId($itemId);
}
+ if (null !== $code = $request->get('code')) {
+ $itemImageQuery->filterByCode($code);
+ }
+
if (null !== $limit = $request->get('limit', 20)) {
$itemImageQuery->limit($limit);
}
@@ -125,7 +136,7 @@ function (LibraryItemImage $itemImage) use ($modelFactory, $locale) {
* )
* ),
* @OA\Parameter(
- * name="slug",
+ * name="code",
* in="query",
* @OA\Schema(
* type="string"
@@ -202,10 +213,8 @@ public function getImage(
$itemImageQuery->filterByItemId($itemId);
}
- if (null !== $slug = $request->get('slug')) {
- $itemImageQuery->useLibraryImageQuery()
- ->filterBySlug($slug)
- ->endUse();
+ if (null !== $code = $request->get('code')) {
+ $itemImageQuery->filterByCode($code);
}
if (true === $request->get('onlyVisible', true)) {
diff --git a/Model/Api/LibraryImage.php b/Model/Api/LibraryImage.php
index e754be6..45b2d23 100755
--- a/Model/Api/LibraryImage.php
+++ b/Model/Api/LibraryImage.php
@@ -6,8 +6,6 @@
use OpenApi\Model\Api\BaseApiModel;
use OpenApi\Constraint as Constraint;
use OpenApi\Model\Api\ModelFactory;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Thelia\TaxEngine\TaxEngine;
@@ -40,14 +38,6 @@ class LibraryImage extends BaseApiModel
*/
protected $title;
- /**
- * @var string
- * @OA\Property(
- * type="string",
- * )
- */
- protected $slug;
-
/**
* @var string
* @OA\Property(
@@ -129,24 +119,6 @@ public function setTitle(?string $title): LibraryImage
return $this;
}
- /**
- * @return string
- */
- public function getSlug(): ?string
- {
- return $this->slug;
- }
-
- /**
- * @param string $slug
- * @return LibraryImage
- */
- public function setSlug(?string $slug): LibraryImage
- {
- $this->slug = $slug;
- return $this;
- }
-
/**
* @return string
*/
diff --git a/Model/Api/LibraryItemImage.php b/Model/Api/LibraryItemImage.php
index e063d69..76c1325 100755
--- a/Model/Api/LibraryItemImage.php
+++ b/Model/Api/LibraryItemImage.php
@@ -59,6 +59,14 @@ class LibraryItemImage extends BaseApiModel
*/
protected $itemId;
+ /**
+ * @var string
+ * @OA\Property(
+ * type="string",
+ * )
+ */
+ protected $code;
+
/**
* @var boolean
* @OA\Property(
@@ -165,6 +173,24 @@ public function setItemId(int $itemId): LibraryItemImage
return $this;
}
+ /**
+ * @return string
+ */
+ public function getCode(): ?string
+ {
+ return $this->code;
+ }
+
+ /**
+ * @param string|null $code
+ * @return LibraryItemImage
+ */
+ public function setCode(?string $code): LibraryItemImage
+ {
+ $this->code = $code;
+ return $this;
+ }
+
/**
* @return bool
*/
diff --git a/Service/LibraryImageService.php b/Service/LibraryImageService.php
index 0aa45bb..8866595 100755
--- a/Service/LibraryImageService.php
+++ b/Service/LibraryImageService.php
@@ -36,20 +36,18 @@ public function __construct(
public function createImage(
UploadedFile $file,
string $title = null,
- string $slug = null,
string $locale = null
): LibraryImage {
- return $this->createOrUpdateImage($file, $title, $slug, $locale);
+ return $this->createOrUpdateImage($file, $title, $locale);
}
public function updateImage(
$imageId,
UploadedFile $file = null,
string $title = null,
- string $slug = null,
string $locale = null
): LibraryImage {
- return $this->createOrUpdateImage($file, $title, $slug, $locale, $imageId);
+ return $this->createOrUpdateImage($file, $title, $locale, $imageId);
}
public function deleteImage(
@@ -117,7 +115,6 @@ public function getImageFilePublicUrl($imageName = null, $width = null, $height
protected function createOrUpdateImage(
UploadedFile $file = null,
string $title = null,
- string $slug = null,
string $locale = null,
int $imageId = null
) {
@@ -143,10 +140,6 @@ protected function createOrUpdateImage(
$image->setTitle($title);
}
- if (null != $slug) {
- $image->setSlug($slug);
- }
-
if (null !== $file) {
// Remove old file if already exist for this locale
if (null !== $image->getFileName()) {
diff --git a/Service/LibraryItemImageService.php b/Service/LibraryItemImageService.php
index 9ebf05e..3f99d03 100755
--- a/Service/LibraryItemImageService.php
+++ b/Service/LibraryItemImageService.php
@@ -30,6 +30,7 @@ public function associateImage(
$imageId,
$itemType,
$itemId,
+ $code = null,
$visible = true,
$position = null
): LibraryItemImage
@@ -38,6 +39,7 @@ public function associateImage(
->setImageId($imageId)
->setItemType($itemType)
->setItemId($itemId)
+ ->setCode($code)
->setVisible($visible);
$itemImage->save();
@@ -51,6 +53,7 @@ public function associateImage(
public function updateImageAssociation(
$itemImageId,
+ $code = null,
$visible = true,
$position = null,
$positionMovement = null
@@ -64,6 +67,7 @@ public function updateImageAssociation(
throw new \Exception(Translator::getInstance()->trans("Can't update an item image that doesn't exist"));
}
+ $itemImage->setCode($code);
$itemImage->setVisible($visible);
$itemImage->save();