diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9f87ca6..5650a0b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -69,7 +69,7 @@ jobs: strategy: fail-fast: true matrix: - shopware: [ '6.4.18.0' ] + shopware: [ '6.5.2.0', ] steps: - name: Clone Code uses: actions/checkout@v3 @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: true matrix: - shopware: [ '6.4.18.0', ] + shopware: [ '6.5.2.0', ] steps: - name: Clone Code uses: actions/checkout@v3 @@ -127,35 +127,3 @@ jobs: docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make clean' docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make install' docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make build' - - integrationphp74: - name: Integration Tests | Shopware ${{ matrix.shopware }} | PHP 7.4 - needs: integration - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - shopware: [ '6.4.6.1', ] - steps: - - name: Clone Code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - - - name: Start Docker - run: | - docker run --rm --name shop --env PHP_VERSION=7.4 -d dockware/dev:${{ matrix.shopware }} - sleep 30 - docker logs shop - - name: Upload into Docker - run: | - docker cp $(pwd)/. shop:/var/www/html/custom/plugins/SasEsd - docker exec shop bash -c 'sudo chown www-data:www-data /var/www/html/custom/plugins -R' - - name: Install and Build Plugin - run: | - docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make clean' - docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make install' - docker exec shop bash -c 'cd /var/www/html/custom/plugins/SasEsd && make build' diff --git a/.phpstan.neon b/.phpstan.neon index 5ba2328..0cc5817 100644 --- a/.phpstan.neon +++ b/.phpstan.neon @@ -6,7 +6,7 @@ parameters: checkGenericClassInNonGenericObjectType: false paths: - ./src - excludes_analyse: + excludePaths: - ./src/Resources/app/administration/node_modules/* - ./src/Resources/app/storefront/node_modules/* - ./tests/* diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index a3233f5..9fb1c0e 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,6 @@ +# 2.0.0 +* Kompatibilität Shopware Version 6.5.2.0+ + # 1.6.3 * Problem behoben, dass Benutzer die Datei ohne Anmeldung herunterladen können. diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index b43f26f..9e64d2e 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,6 @@ +# 2.0.0 +* Compatibility Shopware version 6.5.2.0+ + # 1.6.3 * Fixed issue user can download the file without login. diff --git a/README.md b/README.md index 07a4372..214daa6 100644 --- a/README.md +++ b/README.md @@ -114,11 +114,11 @@ Full **POST** example to the endpoint `/api/v2/sas-product-esd-serial`: ## Add your digital media to the product To add the digital media to the product, we will use the [Bulk Edit API](https://shopware.stoplight.io/docs/admin-api/adminapi.json/paths/~1_action~1sync/post) to do it. -First, we need to upload a media file if it doesn't exist in our store, you can take a look at the Admin-API how to add a media file [here](https://shopware.stoplight.io/docs/admin-api/docs/guides/media-handling.md#upload-the-resource-directly). +First, we need to upload a media file if it doesn't exist in our store, you can take a look at the Admin-API how to add a media file [here](https://shopware.stoplight.io/docs/admin-api/c5267f85b987c-create-a-new-media-resources). After finished adding the media you've got the mediaId, we will use it to add to the product through the Bulk Edit API with my example below. -Full **POST** example to the endpoint `/api/_action/syncl`: +Full **POST** example to the endpoint `/api/_action/sync`: ``` [ { diff --git a/composer.json b/composer.json index 5a426f0..14d0084 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description":"ESD / Download plugin", "type":"shopware-platform-plugin", "keywords": ["esd", "download"], - "version":"1.6.3", + "version":"2.0.0", "license":"proprietary", "authors":[ { @@ -13,9 +13,9 @@ } ], "require":{ - "shopware/core": "~6.4.6", - "shopware/administration": "~6.4.6", - "shopware/storefront": "~6.4.6" + "shopware/core": "~6.5.2", + "shopware/administration": "~6.5.2", + "shopware/storefront": "~6.5.2" }, "require-dev":{ "phpunit/phpunit": "^9.5", @@ -56,5 +56,13 @@ "conflict": { "shopware/storefront": "<6,>=7", "shopware/administration": "<6,>=7" + }, + "config": { + "platform": { + "php": "8.1.0" + }, + "allow-plugins": { + "symfony/runtime": true + } } } diff --git a/phpunit.xml b/phpunit.xml index ee1faae..512981a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ - - - src - - + + + ./src + + diff --git a/src/Api/Controller/EsdSendMailController.php b/src/Api/Controller/EsdSendMailController.php index 75ab533..67932db 100644 --- a/src/Api/Controller/EsdSendMailController.php +++ b/src/Api/Controller/EsdSendMailController.php @@ -4,7 +4,6 @@ use Sas\Esd\Service\EsdMailService; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\Routing\Annotation\RouteScope; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -12,15 +11,12 @@ use Symfony\Component\Routing\Annotation\Route; /** - * @RouteScope(scopes={"api"}) + * @Route(defaults={"_routeScope"={"api"}}) */ class EsdSendMailController extends AbstractController { - private EsdMailService $esdMailService; - - public function __construct(EsdMailService $esdMailService) + public function __construct(private readonly EsdMailService $esdMailService) { - $this->esdMailService = $esdMailService; } /** diff --git a/src/Api/Controller/MediaController.php b/src/Api/Controller/MediaController.php index 2c4ab33..0ac85ed 100644 --- a/src/Api/Controller/MediaController.php +++ b/src/Api/Controller/MediaController.php @@ -17,14 +17,8 @@ */ class MediaController extends AbstractController { - private EsdMediaService $esdMediaService; - - private FileNameProvider $fileNameProvider; - - public function __construct(EsdMediaService $esdMediaService, FileNameProvider $fileNameProvider) + public function __construct(private readonly EsdMediaService $esdMediaService, private readonly FileNameProvider $fileNameProvider) { - $this->esdMediaService = $esdMediaService; - $this->fileNameProvider = $fileNameProvider; } /** diff --git a/src/Checkout/Cart/Subscriber/OrderPlacedSubscriber.php b/src/Checkout/Cart/Subscriber/OrderPlacedSubscriber.php index 65ef26f..55d8c83 100644 --- a/src/Checkout/Cart/Subscriber/OrderPlacedSubscriber.php +++ b/src/Checkout/Cart/Subscriber/OrderPlacedSubscriber.php @@ -14,31 +14,19 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity; use Shopware\Core\Content\Product\ProductCollection; use Shopware\Core\Content\Product\ProductEntity; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; +use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\System\SystemConfig\SystemConfigService; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class OrderPlacedSubscriber { - private EntityRepositoryInterface $productRepository; - - private EsdOrderService $esdOrderService; - - private SystemConfigService $systemConfigService; - - private EventDispatcherInterface $eventDispatcher; - public function __construct( - EntityRepositoryInterface $productRepository, - EsdOrderService $esdOrderService, - SystemConfigService $systemConfigService, - EventDispatcherInterface $eventDispatcher + private readonly EntityRepository $productRepository, + private readonly EsdOrderService $esdOrderService, + private readonly SystemConfigService $systemConfigService, + private readonly EventDispatcherInterface $eventDispatcher ) { - $this->productRepository = $productRepository; - $this->esdOrderService = $esdOrderService; - $this->systemConfigService = $systemConfigService; - $this->eventDispatcher = $eventDispatcher; } public function __invoke(CheckoutOrderPlacedEvent $event): void diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryCollection.php index 172054e..9319f30 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdDownloadHistoryEntity $entity) - * @method void set(string $key, EsdDownloadHistoryEntity $entity) - * @method EsdDownloadHistoryEntity[] getIterator() - * @method EsdDownloadHistoryEntity[] getElements() - * @method EsdDownloadHistoryEntity|null get(string $key) - * @method EsdDownloadHistoryEntity|null first() - * @method EsdDownloadHistoryEntity|null last() + * @extends EntityCollection */ class EsdDownloadHistoryCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryEntity.php index 46b92ac..84ac299 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdDownloadHistory/EsdDownloadHistoryEntity.php @@ -9,10 +9,7 @@ class EsdDownloadHistoryEntity extends Entity { use EntityIdTrait; - /** - * @var string|null - */ - protected $esdOrderId; + protected ?string $esdOrderId = null; public function getId(): string { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaCollection.php index 6c8a3ef..dac96e5 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdMediaEntity $entity) - * @method void set(string $key, EsdMediaEntity $entity) - * @method EsdMediaEntity[] getIterator() - * @method EsdMediaEntity[] getElements() - * @method EsdMediaEntity|null get(string $key) - * @method EsdMediaEntity|null first() - * @method EsdMediaEntity|null last() + * @extends EntityCollection */ class EsdMediaCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaDefinition.php b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaDefinition.php index 63591c6..ac02206 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaDefinition.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaDefinition.php @@ -2,6 +2,7 @@ namespace Sas\Esd\Content\Product\Extension\Esd\Aggregate\EsdMedia; +use Sas\Esd\Content\Product\Extension\Esd\Aggregate\EsdVideo\EsdVideoDefinition; use Sas\Esd\Content\Product\Extension\Esd\EsdDefinition; use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition; @@ -43,6 +44,7 @@ public function defineFields(): FieldCollection (new FkField('media_id', 'mediaId', MediaDefinition::class)), (new OneToOneAssociationField('media', 'media_id', 'id', MediaDefinition::class, true)), + (new OneToOneAssociationField('esdVideo', 'id', 'esd_media_id', EsdVideoDefinition::class, false)), new IntField('download_limit_number', 'downloadLimitNumber'), ]); diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaEntity.php index 993e109..407c6aa 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdMedia/EsdMediaEntity.php @@ -10,25 +10,13 @@ class EsdMediaEntity extends Entity { use EntityIdTrait; - /** - * @var string|null - */ - protected $esdId; - - /** - * @var string|null - */ - protected $mediaId; - - /** - * @var MediaEntity|null - */ - protected $media; - - /** - * @var int|null - */ - protected $downloadLimitNumber; + protected ?string $esdId = null; + + protected ?string $mediaId = null; + + protected ?MediaEntity $media = null; + + protected ?int $downloadLimitNumber = null; public function getId(): string { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryCollection.php index 6d3c5b3..ab1fd51 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdMediaDownloadHistoryEntity $entity) - * @method void set(string $key, EsdMediaDownloadHistoryEntity $entity) - * @method EsdMediaDownloadHistoryEntity[] getIterator() - * @method EsdMediaDownloadHistoryEntity[] getElements() - * @method EsdMediaDownloadHistoryEntity|null get(string $key) - * @method EsdMediaDownloadHistoryEntity|null first() - * @method EsdMediaDownloadHistoryEntity|null last() + * @extends EntityCollection */ class EsdMediaDownloadHistoryCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryEntity.php index bb5b057..fc761d3 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdMediaDownloadHistory/EsdMediaDownloadHistoryEntity.php @@ -9,15 +9,9 @@ class EsdMediaDownloadHistoryEntity extends Entity { use EntityIdTrait; - /** - * @var string - */ - protected $esdOrderId; - - /** - * @var string - */ - protected $esdMediaId; + protected string $esdOrderId; + + protected string $esdMediaId; public function getEsdOrderId(): string { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderCollection.php index 2f6ba61..8741a5f 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdOrderEntity $entity) - * @method void set(string $key, EsdOrderEntity $entity) - * @method EsdOrderEntity[] getIterator() - * @method EsdOrderEntity[] getElements() - * @method EsdOrderEntity|null get(string $key) - * @method EsdOrderEntity|null first() - * @method EsdOrderEntity|null last() + * @extends EntityCollection */ class EsdOrderCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderEntity.php index d411961..99d0717 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdOrder/EsdOrderEntity.php @@ -12,40 +12,19 @@ class EsdOrderEntity extends Entity { use EntityIdTrait; - /** - * @var string - */ - protected $esdId; - - /** - * @var EsdEntity - */ - protected $esd; - - /** - * @var string - */ - protected $orderLineItemId; - - /** - * @var string|null - */ - protected $serialId; - - /** - * @var EsdSerialEntity - */ - protected $serial; - - /** - * @var int|null - */ - protected $countDownload; - - /** - * @var OrderLineItemEntity - */ - protected $orderLineItem; + protected string $esdId; + + protected ?EsdEntity $esd = null; + + protected string $orderLineItemId; + + protected ?string $serialId = null; + + protected ?EsdSerialEntity $serial = null; + + protected ?int $countDownload = null; + + protected ?OrderLineItemEntity $orderLineItem = null; public function getEsdId(): string { @@ -57,12 +36,12 @@ public function setEsdId(string $esdId): void $this->esdId = $esdId; } - public function getEsd(): EsdEntity + public function getEsd(): ?EsdEntity { return $this->esd; } - public function setEsd(EsdEntity $esd): void + public function setEsd(?EsdEntity $esd): void { $this->esd = $esd; } @@ -77,12 +56,12 @@ public function setOrderLineItemId(string $orderLineItemId): void $this->orderLineItemId = $orderLineItemId; } - public function getOrderLineItem(): OrderLineItemEntity + public function getOrderLineItem(): ?OrderLineItemEntity { return $this->orderLineItem; } - public function setOrderLineItem(OrderLineItemEntity $orderLineItem): void + public function setOrderLineItem(?OrderLineItemEntity $orderLineItem): void { $this->orderLineItem = $orderLineItem; } @@ -102,7 +81,7 @@ public function getSerial(): ?EsdSerialEntity return $this->serial; } - public function setSerial(EsdSerialEntity $serial): void + public function setSerial(?EsdSerialEntity $serial): void { $this->serial = $serial; } diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialCollection.php index 0ce5672..078709b 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdSerialEntity $entity) - * @method void set(string $key, EsdSerialEntity $entity) - * @method EsdSerialEntity[] getIterator() - * @method EsdSerialEntity[] getElements() - * @method EsdSerialEntity|null get(string $key) - * @method EsdSerialEntity|null first() - * @method EsdSerialEntity|null last() + * @extends EntityCollection */ class EsdSerialCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialEntity.php index 8b02fed..f159ad4 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdSerial/EsdSerialEntity.php @@ -11,25 +11,13 @@ class EsdSerialEntity extends Entity { use EntityIdTrait; - /** - * @var string - */ - protected $esdId; + protected string $esdId; - /** - * @var EsdEntity - */ - protected $esd; + protected ?EsdEntity $esd = null; - /** - * @var string - */ - protected $serial; + protected string $serial; - /** - * @var EsdOrderEntity|null - */ - protected $esdOrder; + protected ?EsdOrderEntity $esdOrder = null; public function getEsdId(): string { @@ -41,12 +29,12 @@ public function setEsdId(string $esdId): void $this->esdId = $esdId; } - public function getEsd(): EsdEntity + public function getEsd(): ?EsdEntity { return $this->esd; } - public function setEsd(EsdEntity $esd): void + public function setEsd(?EsdEntity $esd): void { $this->esd = $esd; } diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoCollection.php b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoCollection.php index 3fbb574..3a9e335 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoCollection.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdVideoEntity $entity) - * @method void set(string $key, EsdVideoEntity $entity) - * @method EsdVideoEntity[] getIterator() - * @method EsdVideoEntity[] getElements() - * @method EsdVideoEntity|null get(string $key) - * @method EsdVideoEntity|null first() - * @method EsdVideoEntity|null last() + * @extends EntityCollection */ class EsdVideoCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoDefinition.php b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoDefinition.php index fdea2fb..14502b4 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoDefinition.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoDefinition.php @@ -37,7 +37,7 @@ public function defineFields(): FieldCollection (new IdField('id', 'id'))->setFlags(new Required(), new PrimaryKey()), (new FkField('esd_media_id', 'esdMediaId', EsdMediaDefinition::class))->addFlags(new Required()), - new OneToOneAssociationField('esdMedia', 'esd_media_id', 'id', EsdMediaDefinition::class), + new OneToOneAssociationField('esdMedia', 'esd_media_id', 'id', EsdMediaDefinition::class, false), new IntField('option', 'option'), ]); diff --git a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoEntity.php b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoEntity.php index 605b98d..5983d10 100644 --- a/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoEntity.php +++ b/src/Content/Product/Extension/Esd/Aggregate/EsdVideo/EsdVideoEntity.php @@ -9,15 +9,9 @@ class EsdVideoEntity extends Entity { use EntityIdTrait; - /** - * @var string - */ - protected $esdMediaId; - - /** - * @var int - */ - protected $option; + protected string $esdMediaId; + + protected int $option; public function getEsdMediaId(): string { diff --git a/src/Content/Product/Extension/Esd/EsdCollection.php b/src/Content/Product/Extension/Esd/EsdCollection.php index 6203434..c0e91a9 100644 --- a/src/Content/Product/Extension/Esd/EsdCollection.php +++ b/src/Content/Product/Extension/Esd/EsdCollection.php @@ -5,13 +5,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection; /** - * @method void add(EsdEntity $entity) - * @method void set(string $key, EsdEntity $entity) - * @method EsdEntity[] getIterator() - * @method EsdEntity[] getElements() - * @method EsdEntity|null get(string $key) - * @method EsdEntity|null first() - * @method EsdEntity|null last() + * @extends EntityCollection */ class EsdCollection extends EntityCollection { diff --git a/src/Content/Product/Extension/Esd/EsdEntity.php b/src/Content/Product/Extension/Esd/EsdEntity.php index 2353936..f8a24ea 100644 --- a/src/Content/Product/Extension/Esd/EsdEntity.php +++ b/src/Content/Product/Extension/Esd/EsdEntity.php @@ -18,55 +18,25 @@ class EsdEntity extends Entity */ protected $id; - /** - * @var string - */ - protected $productId; + protected string $productId; - /** - * @var ProductEntity|null - */ - protected $product; + protected ?ProductEntity $product = null; - /** - * @var bool - */ - protected $hasSerial; + protected bool $hasSerial; - /** - * @var string|null - */ - protected $mediaId; + protected ?string $mediaId = null; - /** - * @var MediaEntity|null - */ - protected $media; + protected ?MediaEntity $media = null; - /** - * @var EsdMediaCollection|null - */ - protected $esdMedia; + protected ?EsdMediaCollection $esdMedia = null; - /** - * @var bool|null - */ - protected $hasCustomDownloadLimit; + protected ?bool $hasCustomDownloadLimit = null; - /** - * @var bool|null - */ - protected $hasUnlimitedDownload; + protected ?bool $hasUnlimitedDownload = null; - /** - * @var int|null - */ - protected $downloadLimitNumber; + protected ?int $downloadLimitNumber = null; - /** - * @var EsdSerialCollection|null - */ - protected $serial; + protected ?EsdSerialCollection $serial = null; public function getId(): string { diff --git a/src/Event/EsdDownloadPaymentStatusPaidDisabledZipEvent.php b/src/Event/EsdDownloadPaymentStatusPaidDisabledZipEvent.php index 830003d..11829ab 100644 --- a/src/Event/EsdDownloadPaymentStatusPaidDisabledZipEvent.php +++ b/src/Event/EsdDownloadPaymentStatusPaidDisabledZipEvent.php @@ -4,6 +4,7 @@ use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Checkout\Order\OrderEntity; +use Shopware\Core\Content\Flow\Dispatching\Aware\ScalarValuesAware; use Shopware\Core\Content\Flow\Exception\CustomerDeletedException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Exception\AssociationNotFoundException; @@ -18,29 +19,19 @@ use Shopware\Core\Framework\Event\SalesChannelAware; use Symfony\Contracts\EventDispatcher\Event; -class EsdDownloadPaymentStatusPaidDisabledZipEvent extends Event implements SalesChannelAware, OrderAware, MailAware, CustomerAware +class EsdDownloadPaymentStatusPaidDisabledZipEvent extends Event implements ScalarValuesAware, SalesChannelAware, OrderAware, MailAware, CustomerAware { public const EVENT_NAME = 'esd.download.disabled.zip.payment.status.paid'; - private Context $context; - - private OrderEntity $order; - - private array $templateData; - - private ?MailRecipientStruct $mailRecipientStruct; + private ?MailRecipientStruct $mailRecipientStruct = null; private string $salesChannelId; public function __construct( - Context $context, - OrderEntity $order, - array $templateData = [] + private readonly Context $context, + private readonly OrderEntity $order, + private readonly array $templateData = [] ) { - $this->context = $context; - $this->order = $order; - $this->templateData = $templateData; - $this->salesChannelId = $order->getSalesChannelId(); } @@ -104,6 +95,9 @@ public function getContext(): Context return $this->context; } + /** + * @throws CustomerDeletedException + */ public function getCustomerId(): string { $customer = $this->getOrder()->getOrderCustomer(); @@ -119,4 +113,11 @@ public function getOrderId(): string { return $this->order->getId(); } + + public function getValues(): array + { + return [ + 'esdData' => $this->templateData, + ]; + } } diff --git a/src/Event/EsdDownloadPaymentStatusPaidEvent.php b/src/Event/EsdDownloadPaymentStatusPaidEvent.php index 61ee2b5..8ffd06d 100644 --- a/src/Event/EsdDownloadPaymentStatusPaidEvent.php +++ b/src/Event/EsdDownloadPaymentStatusPaidEvent.php @@ -4,6 +4,7 @@ use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Checkout\Order\OrderEntity; +use Shopware\Core\Content\Flow\Dispatching\Aware\ScalarValuesAware; use Shopware\Core\Content\Flow\Exception\CustomerDeletedException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Exception\AssociationNotFoundException; @@ -18,29 +19,19 @@ use Shopware\Core\Framework\Event\SalesChannelAware; use Symfony\Contracts\EventDispatcher\Event; -class EsdDownloadPaymentStatusPaidEvent extends Event implements SalesChannelAware, OrderAware, MailAware, CustomerAware +class EsdDownloadPaymentStatusPaidEvent extends Event implements ScalarValuesAware, SalesChannelAware, OrderAware, MailAware, CustomerAware { public const EVENT_NAME = 'esd.download.payment.status.paid'; - private Context $context; - - private OrderEntity $order; - - private array $templateData; - private ?MailRecipientStruct $mailRecipientStruct; private string $salesChannelId; public function __construct( - Context $context, - OrderEntity $order, - array $templateData = [] + private readonly Context $context, + private readonly OrderEntity $order, + private readonly array $templateData = [] ) { - $this->context = $context; - $this->order = $order; - $this->templateData = $templateData; - $this->salesChannelId = $order->getSalesChannelId(); } @@ -114,6 +105,9 @@ public function getContext(): Context return $this->context; } + /** + * @throws CustomerDeletedException + */ public function getCustomerId(): string { $customer = $this->getOrder()->getOrderCustomer(); @@ -129,4 +123,11 @@ public function getOrderId(): string { return $this->order->getId(); } + + public function getValues(): array + { + return [ + 'esdData' => $this->templateData, + ]; + } } diff --git a/src/Event/EsdSerialPaymentStatusPaidEvent.php b/src/Event/EsdSerialPaymentStatusPaidEvent.php index 9a4619e..9b4bc35 100644 --- a/src/Event/EsdSerialPaymentStatusPaidEvent.php +++ b/src/Event/EsdSerialPaymentStatusPaidEvent.php @@ -4,6 +4,7 @@ use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Checkout\Order\OrderEntity; +use Shopware\Core\Content\Flow\Dispatching\Aware\ScalarValuesAware; use Shopware\Core\Content\Flow\Exception\CustomerDeletedException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Exception\AssociationNotFoundException; @@ -18,26 +19,17 @@ use Shopware\Core\Framework\Event\SalesChannelAware; use Symfony\Contracts\EventDispatcher\Event; -class EsdSerialPaymentStatusPaidEvent extends Event implements SalesChannelAware, OrderAware, MailAware, CustomerAware +class EsdSerialPaymentStatusPaidEvent extends Event implements ScalarValuesAware, SalesChannelAware, OrderAware, MailAware, CustomerAware { public const EVENT_NAME = 'esd.serial.payment.status.paid'; - private Context $context; - - private OrderEntity $order; - - private array $templateData; - private ?MailRecipientStruct $mailRecipientStruct; public function __construct( - Context $context, - OrderEntity $order, - array $templateData = [] + private readonly Context $context, + private readonly OrderEntity $order, + private readonly array $templateData = [] ) { - $this->context = $context; - $this->order = $order; - $this->templateData = $templateData; } public function getOrder(): OrderEntity @@ -95,6 +87,9 @@ public function getContext(): Context return $this->context; } + /** + * @throws CustomerDeletedException + */ public function getCustomerId(): string { $customer = $this->getOrder()->getOrderCustomer(); @@ -110,4 +105,11 @@ public function getOrderId(): string { return $this->order->getId(); } + + public function getValues(): array + { + return [ + 'esdData' => $this->templateData, + ]; + } } diff --git a/src/Event/ReadEsdFileEvent.php b/src/Event/ReadEsdFileEvent.php index cfd6c3e..cff2b1d 100644 --- a/src/Event/ReadEsdFileEvent.php +++ b/src/Event/ReadEsdFileEvent.php @@ -9,12 +9,9 @@ class ReadEsdFileEvent extends NestedEvent { protected Context $context; - protected string $productId; - - public function __construct(string $productId) + public function __construct(protected readonly string $productId) { $this->context = Context::createDefaultContext(); - $this->productId = $productId; } public function getContext(): Context diff --git a/src/Extension/Twig/EsdExtension.php b/src/Extension/Twig/EsdExtension.php index 209efea..0b7ae73 100644 --- a/src/Extension/Twig/EsdExtension.php +++ b/src/Extension/Twig/EsdExtension.php @@ -4,7 +4,7 @@ use Sas\Esd\Content\Product\Extension\Esd\EsdCollection; use Shopware\Core\Framework\Context; -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; +use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter; use Twig\Extension\AbstractExtension; @@ -12,11 +12,8 @@ class EsdExtension extends AbstractExtension { - private EntityRepositoryInterface $esdRepository; - - public function __construct(EntityRepositoryInterface $esdRepository) + public function __construct(private readonly EntityRepository $esdRepository) { - $this->esdRepository = $esdRepository; } public function getFunctions(): array diff --git a/src/Message/CompressMediaHandler.php b/src/Message/CompressMediaHandler.php index 3bd8686..433e0d3 100644 --- a/src/Message/CompressMediaHandler.php +++ b/src/Message/CompressMediaHandler.php @@ -2,30 +2,22 @@ namespace Sas\Esd\Message; +use League\Flysystem\FilesystemException; use Sas\Esd\Service\EsdService; -use Shopware\Core\Framework\MessageQueue\Handler\AbstractMessageHandler; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; -class CompressMediaHandler extends AbstractMessageHandler +#[AsMessageHandler] +class CompressMediaHandler { - private EsdService $service; - - public function __construct(EsdService $service) + public function __construct(private readonly EsdService $service) { - $this->service = $service; } /** - * @param CompressMediaMessage $message - * - * @throws \League\Flysystem\FileNotFoundException + * @throws FilesystemException */ - public function handle($message): void + public function __invoke(CompressMediaMessage $message): void { $this->service->compressFiles($message->getProductId()); } - - public static function getHandledMessages(): iterable - { - return [CompressMediaMessage::class]; - } } diff --git a/src/Migration/Migration1607159480CreateDownloadMailEventAction.php b/src/Migration/Migration1607159480CreateDownloadMailEventAction.php index efb2de0..67c7d23 100644 --- a/src/Migration/Migration1607159480CreateDownloadMailEventAction.php +++ b/src/Migration/Migration1607159480CreateDownloadMailEventAction.php @@ -4,9 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; -use Sas\Esd\Event\EsdDownloadPaymentStatusPaidEvent; use Sas\Esd\Utils\EsdMailTemplate; -use Shopware\Core\Content\MailTemplate\MailTemplateActions; use Shopware\Core\Defaults; use Shopware\Core\Framework\Migration\MigrationStep; use Shopware\Core\Framework\Uuid\Uuid; @@ -32,8 +30,6 @@ public function updateDestructive(Connection $connection): void private function insertEventAction(Connection $connection): void { - $templateId = null; - $templateTypeId = null; $fetchTemplateTypeId = $this->fetchTemplateTypeId(EsdMailTemplate::TEMPLATE_TYPE_DOWNLOAD_TECHNICAL_NAME, $connection); if ($fetchTemplateTypeId) { $templateTypeId = $fetchTemplateTypeId; @@ -44,24 +40,6 @@ private function insertEventAction(Connection $connection): void $this->insertMailTemplateType($templateTypeId, $connection); $this->insertMailTemplate($templateId, $templateTypeId, $connection); } - - if ($templateId && $templateTypeId) { - $connection->insert( - 'event_action', - [ - 'id' => Uuid::randomBytes(), - 'title' => 'ESD - Download mail', - 'event_name' => EsdDownloadPaymentStatusPaidEvent::EVENT_NAME, - 'action_name' => MailTemplateActions::MAIL_TEMPLATE_MAIL_SEND_ACTION, - 'active' => 0, - 'config' => json_encode([ - 'mail_template_type_id' => Uuid::fromBytesToHex($templateTypeId), - 'mail_template_id' => Uuid::fromBytesToHex($templateId), - ]), - 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT), - ] - ); - } } private function insertMailTemplateType(string $templateTypeId, Connection $connection): void diff --git a/src/Migration/Migration1607192450CreateSerialMailEventAction.php b/src/Migration/Migration1607192450CreateSerialMailEventAction.php index 954fbc8..5f247c3 100644 --- a/src/Migration/Migration1607192450CreateSerialMailEventAction.php +++ b/src/Migration/Migration1607192450CreateSerialMailEventAction.php @@ -5,7 +5,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; use Sas\Esd\Utils\EsdMailTemplate; -use Shopware\Core\Content\MailTemplate\MailTemplateActions; use Shopware\Core\Defaults; use Shopware\Core\Framework\Migration\MigrationStep; use Shopware\Core\Framework\Uuid\Uuid; @@ -31,8 +30,6 @@ public function updateDestructive(Connection $connection): void private function insertEventAction(Connection $connection): void { - $templateId = null; - $templateTypeId = null; $fetchTemplateTypeId = $this->fetchTemplateTypeId(EsdMailTemplate::TEMPLATE_TYPE_SERIAL_TECHNICAL_NAME, $connection); if ($fetchTemplateTypeId) { $templateTypeId = $fetchTemplateTypeId; @@ -43,24 +40,6 @@ private function insertEventAction(Connection $connection): void $this->insertMailTemplateType($templateTypeId, $connection); $this->insertMailTemplate($templateId, $templateTypeId, $connection); } - - if ($templateId && $templateTypeId) { - $connection->insert( - 'event_action', - [ - 'id' => Uuid::randomBytes(), - 'title' => 'ESD - Serial mail', - 'event_name' => 'esd.serial.payment.status.paid', - 'action_name' => MailTemplateActions::MAIL_TEMPLATE_MAIL_SEND_ACTION, - 'active' => 0, - 'config' => json_encode([ - 'mail_template_type_id' => Uuid::fromBytesToHex($templateTypeId), - 'mail_template_id' => Uuid::fromBytesToHex($templateId), - ]), - 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT), - ] - ); - } } private function insertMailTemplateType(string $templateTypeId, Connection $connection): void diff --git a/src/Migration/Migration1617902528CreateDownloadMailEventActionForDisabledZip.php b/src/Migration/Migration1617902528CreateDownloadMailEventActionForDisabledZip.php index e563771..947f63a 100644 --- a/src/Migration/Migration1617902528CreateDownloadMailEventActionForDisabledZip.php +++ b/src/Migration/Migration1617902528CreateDownloadMailEventActionForDisabledZip.php @@ -4,9 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; -use Sas\Esd\Event\EsdDownloadPaymentStatusPaidDisabledZipEvent; use Sas\Esd\Utils\EsdMailTemplate; -use Shopware\Core\Content\MailTemplate\MailTemplateActions; use Shopware\Core\Defaults; use Shopware\Core\Framework\Migration\MigrationStep; use Shopware\Core\Framework\Uuid\Uuid; @@ -33,8 +31,6 @@ public function updateDestructive(Connection $connection): void private function insertEventAction(Connection $connection): void { - $templateId = null; - $templateTypeId = null; $fetchTemplateTypeId = $this->fetchTemplateTypeId( EsdMailTemplate::TEMPLATE_TYPE_DOWNLOAD_DISABLED_ZIP_TECHNICAL_NAME, $connection @@ -48,24 +44,6 @@ private function insertEventAction(Connection $connection): void $this->insertMailTemplateType($templateTypeId, $connection); $this->insertMailTemplate($templateId, $templateTypeId, $connection); } - - if ($templateId && $templateTypeId) { - $connection->insert( - 'event_action', - [ - 'id' => Uuid::randomBytes(), - 'title' => 'ESD - Download mail with disabled zip', - 'event_name' => EsdDownloadPaymentStatusPaidDisabledZipEvent::EVENT_NAME, - 'action_name' => MailTemplateActions::MAIL_TEMPLATE_MAIL_SEND_ACTION, - 'active' => 0, - 'config' => json_encode([ - 'mail_template_type_id' => Uuid::fromBytesToHex($templateTypeId), - 'mail_template_id' => Uuid::fromBytesToHex($templateId), - ]), - 'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT), - ] - ); - } } private function insertMailTemplate(string $templateId, string $templateTypeId, Connection $connection): void diff --git a/src/Resources/app/administration/build/webpack.config.js b/src/Resources/app/administration/build/webpack.config.js new file mode 100644 index 0000000..d98ea96 --- /dev/null +++ b/src/Resources/app/administration/build/webpack.config.js @@ -0,0 +1,18 @@ +const { join, resolve } = require('path'); +module.exports = () => { + return { + resolve: { + alias: { + '@lodash': resolve( + join(__dirname, '..', 'node_modules', 'lodash') + ), + '@mime-types': resolve( + join(__dirname, '..', 'node_modules', 'mime-types') + ), + '@papaparse': resolve( + join(__dirname, '..', 'node_modules', 'papaparse') + ), + } + } + }; +} diff --git a/src/Resources/app/administration/src/module/sas-esd/component/sas-esd-modal-csv/index.js b/src/Resources/app/administration/src/module/sas-esd/component/sas-esd-modal-csv/index.js index ebd0a4e..f8c69e8 100644 --- a/src/Resources/app/administration/src/module/sas-esd/component/sas-esd-modal-csv/index.js +++ b/src/Resources/app/administration/src/module/sas-esd/component/sas-esd-modal-csv/index.js @@ -1,9 +1,9 @@ import template from './sas-esd-modal-csv.html.twig'; import './sas-esd-modal-csv.scss'; -import { drop, every, forEach, get, isArray, map, set } from 'lodash'; -import Papa from 'papaparse'; -import mimeTypes from "mime-types"; +import { drop, every, forEach, get, isArray, map, set } from '@lodash'; +import Papa from '@papaparse'; +import mimeTypes from "@mime-types"; const { Component, Mixin } = Shopware; const { mapState } = Shopware.Component.getComponentHelper(); diff --git a/src/Resources/app/administration/src/module/sas-esd/component/sas-product-esd-form/sas-product-esd-form.html.twig b/src/Resources/app/administration/src/module/sas-esd/component/sas-product-esd-form/sas-product-esd-form.html.twig index 06d2111..da71c47 100644 --- a/src/Resources/app/administration/src/module/sas-esd/component/sas-product-esd-form/sas-product-esd-form.html.twig +++ b/src/Resources/app/administration/src/module/sas-esd/component/sas-product-esd-form/sas-product-esd-form.html.twig @@ -1,7 +1,7 @@ {% block sas_product_esd_form %}
{% block sas_prduct_esd_form_card %} - + {% block sas_prduct_esd_form_context_menu %}
diff --git a/src/Resources/app/administration/src/module/sas-esd/page/sas-product-detail-esd/sas-product-detail-esd.html.twig b/src/Resources/app/administration/src/module/sas-esd/page/sas-product-detail-esd/sas-product-detail-esd.html.twig index 11c7b12..604ae29 100644 --- a/src/Resources/app/administration/src/module/sas-esd/page/sas-product-detail-esd/sas-product-detail-esd.html.twig +++ b/src/Resources/app/administration/src/module/sas-esd/page/sas-product-detail-esd/sas-product-detail-esd.html.twig @@ -1,5 +1,5 @@
- +