Skip to content

Commit

Permalink
Merge pull request #20 from odiseoteam/1.1
Browse files Browse the repository at this point in the history
Update Sylius 1.12 and Symfony 6.4
  • Loading branch information
bigboss86 authored Mar 22, 2024
2 parents 23523f7 + 6167a7b commit 41fed79
Show file tree
Hide file tree
Showing 74 changed files with 281 additions and 658 deletions.
42 changes: 22 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,39 @@ on:

jobs:
tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"

strategy:
fail-fast: false
matrix:
php: ["7.4", "8.0"]
symfony: ["^5.4"]
sylius: ["~1.10.0", '~1.11.0']
node: ["14.x"]
php: ["8.0", "8.1"]
symfony: ["5.4.*", "^6.0"]
sylius: ["^1.12"]
node: ["14.x", "16.x", "18.x"]
mysql: ["5.7", "8.0"]

exclude:
-
php: "7.4"
sylius: "~1.11.0"

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"

steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: intl
tools: symfony
tools: flex,symfony
coverage: none

-
name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: "${{ matrix.node }}"

Expand Down Expand Up @@ -85,22 +80,27 @@ jobs:
-
name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

-
name: Cache Composer
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
-
name: Configure global composer
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2"
-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
-
Expand All @@ -111,15 +111,17 @@ jobs:
-
name: Install PHP dependencies
run: composer install --no-interaction
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}

-
name: Get Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
Expand All @@ -140,7 +142,7 @@ jobs:
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
(cd tests/Application && yarn build:prod)
-
name: Prepare test application cache
Expand Down Expand Up @@ -184,7 +186,7 @@ jobs:

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: Behat logs
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
/behat.yml
/phpspec.yml
/phpunit.xml

# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<img src="https://img.shields.io/packagist/v/odiseoteam/sylius-referrals-plugin.svg" />
</a>
<a href="https://github.com/odiseoteam/SyliusReferralsPlugin/actions" title="Build Status" target="_blank">
<img src="https://img.shields.io/github/workflow/status/odiseoteam/SyliusReferralsPlugin/Build" />
<img src="https://img.shields.io/github/actions/workflow/status/odiseoteam/SyliusReferralsPlugin/build.yml" />
</a>
<a href="https://scrutinizer-ci.com/g/odiseoteam/SyliusReferralsPlugin/" title="Scrutinizer" target="_blank">
<img src="https://img.shields.io/scrutinizer/g/odiseoteam/SyliusReferralsPlugin.svg" />
Expand All @@ -21,7 +21,7 @@
<a href="https://sylius-devs.slack.com" title="Slack" target="_blank">
<img src="https://img.shields.io/badge/community%20chat-slack-FF1493.svg" />
</a>
<a href="https://odiseo.io/contact?utm_source=github&utm_medium=referral&utm_campaign=plugins_referrals" title="Support" target="_blank">
<a href="https://odiseo.io/contact-us" title="Support" target="_blank">
<img src="https://img.shields.io/badge/support-contact%20author-blue" />
</a>
</p>
Expand All @@ -46,7 +46,7 @@ You can add your own reward type following this [guide](doc/rewards.md).



**Support Sylius version 1.10+.**
Support Sylius version 1.9+.

## Demo

Expand Down
45 changes: 28 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"description": "Referrals plugin for Sylius. Affiliate program",
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"sylius/sylius": "^1.10"
"php": "^8.0",
"sylius/sylius": "^1.12",
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
"symfony/webpack-encore-bundle": "^1.15"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand All @@ -26,32 +28,41 @@
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"phpspec/phpspec": "^7.0",
"phpspec/phpspec": "^7.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-doctrine": "0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpstan/phpstan": "^1.8.1",
"phpstan/phpstan-doctrine": "1.3.40",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4",
"symfony/dotenv": "^5.4",
"symfony/intl": "^5.4",
"symfony/web-profiler-bundle": "^5.4",
"vimeo/psalm": "4.7.1"
"sylius-labs/coding-standard": "^4.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/flex": "^2.2.2",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "5.12.0"
},
"conflict": {
"symfony/framework-bundle": "6.2.8",
"api-platform/core": "2.7.17",
"behat/mink-selenium2-driver": ">=1.7.0"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false,
"phpstan/extension-installer": false,
"phpstan/extension-installer": true,
"symfony/flex": true
}
},
"extra": {
"symfony": {
"require": "^5.4 || ^6.0"
}
},
"autoload": {
"psr-4": {
"Odiseo\\SyliusReferralsPlugin\\": "src/",
Expand Down
18 changes: 12 additions & 6 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests/Behat',
__DIR__ . '/ecs.php',
]);

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
$ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php');

$containerConfigurator->parameters()->set(Option::SKIP, [
$ecsConfig->skip([
VisibilityRequiredFixer::class => ['*Spec.php'],
]);
};
11 changes: 10 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
parameters:
level: max
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
paths:
- src
- tests/Behat

excludes_analyse:
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

Expand All @@ -13,3 +17,8 @@ parameters:

ignoreErrors:
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
- '/Cannot cast mixed to int./'
- '/Cannot cast mixed to string./'
-
message: '/but returns mixed./'
path: src/Repository
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@
<PossiblyUndefinedMethod errorLevel="info" />
<MixedMethodCall errorLevel="info" />
<PossiblyInvalidArgument errorLevel="info" />
<MissingTemplateParam errorLevel="info" />
<MixedArrayAssignment errorLevel="info" />
<MixedArgumentTypeCoercion errorLevel="info" />
<TooManyArguments errorLevel="info" />
<MixedOperand errorLevel="info" />
<MixedArrayAccess errorLevel="info" />
</issueHandlers>
</psalm>
7 changes: 2 additions & 5 deletions src/Assigner/AffiliateReferralAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@

final class AffiliateReferralAssigner implements AffiliateReferralAssignerInterface
{
private AffiliateReferralRepositoryInterface $affiliateReferralRepository;

public function __construct(
AffiliateReferralRepositoryInterface $affiliateReferralRepository
private AffiliateReferralRepositoryInterface $affiliateReferralRepository,
) {
$this->affiliateReferralRepository = $affiliateReferralRepository;
}

public function assign(OrderInterface $order): void
Expand All @@ -30,7 +27,7 @@ public function assign(OrderInterface $order): void

/** @var AffiliateReferralInterface|null $affiliateReferral */
$affiliateReferral = $this->affiliateReferralRepository->findOneBy([
'tokenValue' => $session->get(AffiliateReferralInterface::TOKEN_PARAM_NAME)
'tokenValue' => $session->get(AffiliateReferralInterface::TOKEN_PARAM_NAME),
]);

if (null === $affiliateReferral) {
Expand Down
27 changes: 8 additions & 19 deletions src/Controller/Shop/CreateFromProductAffiliateReferralAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,13 @@

final class CreateFromProductAffiliateReferralAction
{
private CustomerContextInterface $customerContext;
private ProductRepositoryInterface $productRepository;
private AffiliateReferralGeneratorInterface $affiliateReferralGenerator;
private AffiliateReferralRepositoryInterface $affiliateReferralRepository;
private RouterInterface $router;

public function __construct(
CustomerContextInterface $customerContext,
ProductRepositoryInterface $productRepository,
AffiliateReferralGeneratorInterface $affiliateReferralGenerator,
AffiliateReferralRepositoryInterface $affiliateReferralRepository,
RouterInterface $router
private CustomerContextInterface $customerContext,
private ProductRepositoryInterface $productRepository,
private AffiliateReferralGeneratorInterface $affiliateReferralGenerator,
private AffiliateReferralRepositoryInterface $affiliateReferralRepository,
private RouterInterface $router,
) {
$this->customerContext = $customerContext;
$this->productRepository = $productRepository;
$this->affiliateReferralGenerator = $affiliateReferralGenerator;
$this->affiliateReferralRepository = $affiliateReferralRepository;
$this->router = $router;
}

public function __invoke(Request $request): Response
Expand All @@ -64,7 +53,7 @@ public function __invoke(Request $request): Response

$affiliateReferral = $this->affiliateReferralRepository->findOneByAffiliateAndProductNotExpired(
$customer,
$product
$product,
);

if ($affiliateReferral === null) {
Expand All @@ -90,9 +79,9 @@ private function generateLink(AffiliateReferralInterface $affiliateReferral): st
'sylius_shop_product_show',
[
'slug' => $product->getSlug(),
AffiliateReferralInterface::TOKEN_PARAM_NAME => $affiliateReferral->getTokenValue()
AffiliateReferralInterface::TOKEN_PARAM_NAME => $affiliateReferral->getTokenValue(),
],
UrlGeneratorInterface::ABSOLUTE_URL
UrlGeneratorInterface::ABSOLUTE_URL,
);
}
}
Loading

0 comments on commit 41fed79

Please sign in to comment.