[11/06/2024] Les premières modifs + installation de quelques modules indispensables

This commit is contained in:
2024-06-11 14:57:59 +02:00
parent 5ac5653ae5
commit 77cf2c7cc6
1626 changed files with 171457 additions and 131 deletions

View File

@@ -0,0 +1,233 @@
<?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\Model\Api;
use OpenApi\Annotations as OA;
use OpenApi\Constraint;
use OpenApi\Model\Api\BaseApiModel;
use OpenApi\Model\Api\ModelFactory;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Thelia\TaxEngine\TaxEngine;
use TheliaLibrary\Model\LibraryImageTagQuery;
use TheliaLibrary\Model\LibraryTagQuery;
use TheliaLibrary\Service\LibraryImageService;
/**
* Class LibraryImage.
*
* @OA\Schema(
* schema="LibraryImage",
* title="LibraryImage",
* )
*/
class LibraryImage extends BaseApiModel
{
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $id;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $title;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $fileName;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $url = null;
protected $width = null;
protected $height = null;
/**
* @var array
* @OA\Property(
* readOnly=true,
* type="array",
* @OA\Items(type="string")
* )
*/
protected $tags = [];
/**
* @var LibraryImageService
*/
protected $libraryImageService;
public function __construct(
ModelFactory $modelFactory,
RequestStack $requestStack,
TaxEngine $taxEngine,
EventDispatcherInterface $dispatcher,
LibraryImageService $libraryImageService,
ValidatorInterface $validator
) {
parent::__construct($modelFactory, $requestStack, $taxEngine, $dispatcher, $validator);
$this->libraryImageService = $libraryImageService;
}
public function createOrUpdateFromData($data, $locale = null): void
{
parent::createOrUpdateFromData($data, $locale);
}
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName = null): self
{
$this->fileName = $fileName;
return $this;
}
/**
* @return string
*/
public function getUrl(): ?string
{
return $this->libraryImageService->getImagePublicUrl($this->getTheliaModel(), $this->width, $this->height);
}
/**
* @param null $width
*/
public function setWidth($width): void
{
$this->width = $width;
}
/**
* @param null $height
*/
public function setHeight($height): void
{
$this->height = $height;
}
public function getTags(): array
{
return $this->tags;
}
/**
* @param array $tags
*/
public function setTags($tags): void
{
$this->tags = $tags;
}
protected function getTheliaModel($propelModelName = null)
{
return parent::getTheliaModel(\TheliaLibrary\Model\LibraryImage::class);
}
public function createFromTheliaModel($theliaModel, $locale = null): void
{
parent::createFromTheliaModel($theliaModel, $locale);
$tags = array_map(
function ($item) use ($locale) {
$query = LibraryTagQuery::create()
->filterById($item['TagId'])
->useI18nQuery()
->filterByLocale($locale)
->filterById($item['TagId'])
->endUse()
->with('LibraryTagI18n');
$tag = $query->find()->getFirst();
$association = LibraryImageTagQuery::create()->filterByImageId($this->getId())->filterByTagId($tag->getId())->findOne();
return [
'tag' => [
'id' => $tag->getId(),
'title' => $tag->getTitle(),
'colorCode' => $tag->getColorCode(),
],
'imageTag' => [
'id' => $association->getId(),
'imageId' => $this->getId(),
'tagId' => $tag->getId(),
],
];
},
LibraryImageTagQuery::create()
->filterByImageId($this->getId())
->find()
->toArray()
);
$this->setTags($tags);
}
}

View File

@@ -0,0 +1,100 @@
<?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\Model\Api;
use OpenApi\Annotations as OA;
use OpenApi\Constraint;
use OpenApi\Model\Api\BaseApiModel;
/**
* Class LibraryImageTag.
*
* @OA\Schema(
* schema="LibraryImageTag",
* title="LibraryImageTag",
* )
*/
class LibraryImageTag extends BaseApiModel
{
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $id;
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $imageId;
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $tagId;
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getImageId(): ?int
{
return $this->imageId;
}
public function setImageId(int $id): self
{
$this->imageId = $id;
return $this;
}
/**
* @return int
*/
public function getTagId(): ?int
{
return $this->tagId;
}
public function setTagId(int $tagId): self
{
$this->tagId = $tagId;
return $this;
}
}

View File

@@ -0,0 +1,213 @@
<?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\Model\Api;
use OpenApi\Annotations as OA;
use OpenApi\Constraint;
use OpenApi\Model\Api\BaseApiModel;
/**
* Class LibraryItemImage.
*
* @OA\Schema(
* schema="LibraryItemImage",
* title="LibraryItemImage",
* )
*/
class LibraryItemImage extends BaseApiModel
{
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $id;
/**
* @var int
* @OA\Property(
* type="integer",
* )
*/
protected $imageId;
/**
* @var LibraryImage
* @OA\Property(
* readOnly=true,
* ref="#/components/schemas/LibraryImage"
* )
*/
protected $image;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $itemType;
/**
* @var int
* @OA\Property(
* type="integer",
* )
*/
protected $itemId;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $code;
/**
* @var bool
* @OA\Property(
* type="boolean",
* )
*/
protected $visible = true;
/**
* @var int
* @OA\Property(
* type="integer",
* )
*/
protected $position;
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return LibraryImage
*/
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getImageId(): int
{
return $this->imageId;
}
/**
* @return LibraryImage
*/
public function getImage(): ?LibraryImage
{
return $this->image;
}
public function setLibraryImage(LibraryImage $image): self
{
$this->image = $image;
return $this;
}
public function setImageId(int $imageId): self
{
$this->imageId = $imageId;
return $this;
}
public function getItemType(): string
{
return $this->itemType;
}
public function setItemType(string $itemType): self
{
$this->itemType = $itemType;
return $this;
}
public function getItemId(): int
{
return $this->itemId;
}
public function setItemId(int $itemId): self
{
$this->itemId = $itemId;
return $this;
}
/**
* @return string
*/
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function isVisible(): bool
{
return $this->visible;
}
public function setVisible(bool $visible = true): self
{
$this->visible = $visible;
return $this;
}
/**
* @return int
*/
public function getPosition(): ?int
{
return $this->position;
}
/**
* @param int $position
*/
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
protected function getTheliaModel($propelModelName = null)
{
return parent::getTheliaModel(\TheliaLibrary\Model\LibraryItemImage::class);
}
}

View File

@@ -0,0 +1,101 @@
<?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\Model\Api;
use OpenApi\Annotations as OA;
use OpenApi\Constraint;
use OpenApi\Model\Api\BaseApiModel;
/**
* Class LibraryTag.
*
* @OA\Schema(
* schema="LibraryTag",
* title="LibraryTag",
* )
*/
class LibraryTag extends BaseApiModel
{
/**
* @var int
* @OA\Property(
* type="integer",
* )
* @Constraint\NotBlank(groups={"read"})
*/
protected $id;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $title;
/**
* @var string
* @OA\Property(
* type="string",
* )
*/
protected $colorCode;
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getColorCode(): ?string
{
return $this->colorCode;
}
public function setColorCode(?string $colorCode = null): self
{
$this->colorCode = $colorCode;
return $this;
}
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImage as BaseLibraryImage;
/**
* Skeleton subclass for representing a row from the 'library_image' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImage extends BaseLibraryImage
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImageI18n as BaseLibraryImageI18n;
/**
* Skeleton subclass for representing a row from the 'library_image_i18n' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImageI18n extends BaseLibraryImageI18n
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImageI18nQuery as BaseLibraryImageI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_image_i18n' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImageI18nQuery extends BaseLibraryImageI18nQuery
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImageQuery as BaseLibraryImageQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_image' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImageQuery extends BaseLibraryImageQuery
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImageTag as BaseLibraryImageTag;
/**
* Skeleton subclass for representing a row from the 'library_image_tag' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImageTag extends BaseLibraryImageTag
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryImageTagQuery as BaseLibraryImageTagQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_image_tag' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryImageTagQuery extends BaseLibraryImageTagQuery
{
}

View File

@@ -0,0 +1,65 @@
<?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\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Tools\PositionManagementTrait;
use TheliaLibrary\Model\Base\LibraryItemImage as BaseLibraryItemImage;
/**
* Skeleton subclass for representing a row from the 'library_item_image' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryItemImage extends BaseLibraryItemImage
{
use PositionManagementTrait;
/**
* Calculate next position relative to our product.
*/
protected function addCriteriaToPositionQuery($query): void
{
/* @var $query LibraryItemImageQuery */
$query->filterByItemId($this->getItemId())
->filterByItemType($this->getItemType());
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setPosition($this->getNextPosition());
parent::preInsert($con);
return true;
}
public function preDelete(ConnectionInterface $con = null)
{
parent::preDelete($con);
$this->reorderBeforeDelete(
[
'item_id' => $this->getItemId(),
'item_type' => $this->getItemType(),
]
);
return true;
}
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryItemImageQuery as BaseLibraryItemImageQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_item_image' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryItemImageQuery extends BaseLibraryItemImageQuery
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryTag as BaseLibraryTag;
/**
* Skeleton subclass for representing a row from the 'library_tag' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryTag extends BaseLibraryTag
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryTagI18n as BaseLibraryTagI18n;
/**
* Skeleton subclass for representing a row from the 'library_tag_i18n' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryTagI18n extends BaseLibraryTagI18n
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryTagI18nQuery as BaseLibraryTagI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_tag_i18n' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryTagI18nQuery extends BaseLibraryTagI18nQuery
{
}

View File

@@ -0,0 +1,26 @@
<?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\Model;
use TheliaLibrary\Model\Base\LibraryTagQuery as BaseLibraryTagQuery;
/**
* Skeleton subclass for performing query and update operations on the 'library_tag' table.
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
class LibraryTagQuery extends BaseLibraryTagQuery
{
}