Skip to content

Commit

Permalink
Merge pull request #82 from patrickleo175/master2
Browse files Browse the repository at this point in the history
6.5 Compatible
  • Loading branch information
ChristopherDosin authored Oct 7, 2023
2 parents ecbc6bd + 1f54b11 commit 8bd5244
Show file tree
Hide file tree
Showing 99 changed files with 643 additions and 1,166 deletions.
36 changes: 2 additions & 34 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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'
2 changes: 1 addition & 1 deletion .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
3 changes: 3 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
```
[
{
Expand Down
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":[
{
Expand All @@ -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",
Expand Down Expand Up @@ -56,5 +56,13 @@
"conflict": {
"shopware/storefront": "<6,>=7",
"shopware/administration": "<6,>=7"
},
"config": {
"platform": {
"php": "8.1.0"
},
"allow-plugins": {
"symfony/runtime": true
}
}
}
12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="phpunit.autoload.php"
bootstrap="tests/TestBootstrap.php"
cacheResult="false"
colors="true"
resolveDependencies="true"
Expand All @@ -12,9 +12,9 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
</phpunit>
8 changes: 2 additions & 6 deletions src/Api/Controller/EsdSendMailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@

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;
use Symfony\Component\HttpFoundation\Response;
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;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Api/Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
22 changes: 5 additions & 17 deletions src/Checkout/Cart/Subscriber/OrderPlacedSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EsdDownloadHistoryEntity>
*/
class EsdDownloadHistoryCollection extends EntityCollection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ class EsdDownloadHistoryEntity extends Entity
{
use EntityIdTrait;

/**
* @var string|null
*/
protected $esdOrderId;
protected ?string $esdOrderId = null;

public function getId(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EsdMediaEntity>
*/
class EsdMediaCollection extends EntityCollection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EsdMediaDownloadHistoryEntity>
*/
class EsdMediaDownloadHistoryCollection extends EntityCollection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EsdOrderEntity>
*/
class EsdOrderCollection extends EntityCollection
{
Expand Down
Loading

0 comments on commit 8bd5244

Please sign in to comment.