Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/backwards-compatibility-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
php-version: "8.2"
coverage: "none"

- name: "Install tool"
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions
- "8.2" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions

dependencies:
- "highest"
Expand Down Expand Up @@ -59,10 +59,10 @@ jobs:
continue-on-error: true

- name: "Lint yaml files"
run: "(cd tests/Application && bin/console lint:yaml ../../src/Resources)"
run: "vendor/bin/console lint:yaml src/Resources"

- name: "Lint twig files"
run: "(cd tests/Application && bin/console lint:twig ../../src/Resources)"
run: "vendor/bin/console lint:twig src/Resources"

dependency-analysis:
name: "Dependency Analysis (PHP${{ matrix.php-version }} | Deps: ${{ matrix.dependencies }} | SF${{ matrix.symfony }})"
Expand All @@ -72,16 +72,16 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "lowest"
- "highest"

symfony:
- "~5.4.0"
- "~6.4.0"
- "~7.3.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -119,16 +119,16 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "lowest"
- "highest"

symfony:
- "~5.4.0"
- "~6.4.0"
- "~7.3.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -163,16 +163,16 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "lowest"
- "highest"

symfony:
- "~5.4.0"
- "~6.4.0"
- "~7.3.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -204,16 +204,16 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"

dependencies:
- "lowest"
- "highest"

symfony:
- "~5.4.0"
- "~6.4.0"
- "~7.3.0"

steps:
- name: "Start MySQL"
Expand All @@ -238,16 +238,16 @@ jobs:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Lint container"
run: "(cd tests/Application && bin/console lint:container)"
run: "vendor/bin/console lint:container"

- name: "Create database"
run: "(cd tests/Application && bin/console doctrine:database:create)"
run: "vendor/bin/console doctrine:database:create"

- name: "Create database schema"
run: "(cd tests/Application && bin/console doctrine:schema:create)"
run: "vendor/bin/console doctrine:schema:create"

- name: "Validate Doctrine mapping"
run: "(cd tests/Application && bin/console doctrine:schema:validate)"
run: "vendor/bin/console doctrine:schema:validate"

mutation-tests:
name: "Mutation tests"
Expand All @@ -257,7 +257,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

dependencies:
- "highest"
Expand Down Expand Up @@ -291,7 +291,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

dependencies:
- "highest"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/.build/
/var/
/vendor/
/node_modules/
/composer.lock

/tests/Application/yarn.lock
/tests/TestApplication/.env.local
/tests/TestApplication/.env.*.local

/.phpunit.result.cache

Expand Down
46 changes: 3 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,20 @@ in the `config/bundles.php` file of your project:
# config/bundles.php
return [
// ...

Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::class => ['all' => true],

// It is important to add plugin before the grid bundle
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],

// ...
Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::class => ['all' => true]
];
```

**NOTE** that you must instantiate the plugin before the grid bundle, else you will see an exception like `You have requested a non-existent parameter "setono_sylius_terms.model.terms.class".`

### Step 3: Import routing

```yaml
# config/routes/setono_sylius_terms.yaml

setono_sylius_terms:
resource: "@SetonoSyliusTermsPlugin/Resources/config/routes.yaml"
resource: "@SetonoSyliusTermsPlugin/config/routes.yaml"
```

There's also a version for non-localized stores: `@SetonoSyliusTermsPlugin/Resources/config/routes_no_locale.yaml`
There's also a version for non-localized stores: `@SetonoSyliusTermsPlugin/config/routes_no_locale.yaml`

### Step 4: Update your database schema

Expand All @@ -83,38 +75,6 @@ $ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
```

### Step 5: Override checkout complete form

Override the [Sylius Form](https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig):

* If you haven't your own `templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig` yet:

```bash
$ cp vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig \
templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig
```

* If you already have it:

Add terms field (exactly this conditional way):

```twig
{# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #}
{% if form.terms is defined %}
{{ form_row(form.terms) }}
{% endif %}
```

So the final template will look like this:

```twig
{# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #}
{{ form_row(form.notes, {'attr': {'rows': 3}}) }}
{% if form.terms is defined %}
{{ form_row(form.terms) }}
{% endif %}
```

# Troubleshooting

* If you see `Neither the property "terms" nor one of the methods "terms()", "getterms()"/"isterms()"/"hasterms()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".`
Expand Down
4 changes: 4 additions & 0 deletions assets/admin/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
4 changes: 4 additions & 0 deletions assets/shop/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"controllers": [],
"entrypoints": []
}
File renamed without changes.
70 changes: 36 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,52 @@
"terms"
],
"require": {
"php": ">=8.1",
"doctrine/collections": "^1.6",
"php": "^8.2",
"doctrine/collections": "^2.2",
"doctrine/orm": "^2.7",
"fakerphp/faker": "^1.23",
"knplabs/knp-menu": "^3.1",
"sylius/channel": "^1.0",
"sylius/channel-bundle": "^1.0",
"sylius/core": "^1.0",
"sylius/core-bundle": "^1.0",
"sylius/locale": "^1.0",
"sylius/core-bundle": "^2.0",
"sylius/resource-bundle": "^1.6",
"sylius/ui-bundle": "^1.0",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0",
"symfony/form": "^5.4 || ^6.4 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"symfony/routing": "^5.4 || ^6.4 || ^7.0",
"symfony/string": "^5.4 || ^6.4 || ^7.0",
"sylius/twig-extra": "^0.8",
"sylius/twig-hooks": "^0.8",
"symfony/config": "^6.4 || ^7.3",
"symfony/dependency-injection": "^6.4 || ^7.3",
"symfony/event-dispatcher": "^6.4 || ^7.3",
"symfony/form": "^6.4 || ^7.3",
"symfony/http-foundation": "^6.4 || ^7.3",
"symfony/http-kernel": "^6.4 || ^7.3",
"symfony/options-resolver": "^6.4 || ^7.3",
"symfony/routing": "^6.4 || ^7.3",
"symfony/string": "^6.4 || ^7.3",
"symfony/translation-contracts": "^1.1 || ^2.4 || ^3.4",
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.3",
"twig/twig": "^2.14 || ^3.8",
"webmozart/assert": "^1.11"
},
"require-dev": {
"api-platform/core": "^2.7.16",
"babdev/pagerfanta-bundle": "^3.8",
"babdev/pagerfanta-bundle": "^4.4",
"behat/behat": "^3.14",
"doctrine/doctrine-bundle": "^2.11",
"infection/infection": "^0.27.9",
"jms/serializer-bundle": "^4.2",
"lexik/jwt-authentication-bundle": "^2.17",
"lexik/jwt-authentication-bundle": "^3.1",
"matthiasnoback/symfony-config-test": "^4.3 || ^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0",
"phpspec/prophecy-phpunit": "^2.1",
"phpunit/phpunit": "^9.6",
"psalm/plugin-phpunit": "^0.18",
"setono/code-quality-pack": "^2.7",
"sylius/sylius": "~1.12.13",
"symfony/debug-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/dotenv": "^5.4 || ^6.4 || ^7.0",
"symfony/intl": "^5.4 || ^6.4 || ^7.0",
"symfony/property-info": "^5.4 || ^6.4 || ^7.0",
"symfony/serializer": "^5.4 || ^6.4 || ^7.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/webpack-encore-bundle": "^1.17",
"sylius/sylius": "^2.0",
"sylius/test-application": "^2.0.0@alpha",
"symfony/debug-bundle": "^6.4 || ^7.3",
"symfony/dotenv": "^6.4 || ^7.3",
"symfony/intl": "^6.4 || ^7.3",
"symfony/property-info": "^6.4 || ^7.3",
"symfony/serializer": "^6.4 || ^7.3",
"symfony/web-profiler-bundle": "^6.4 || ^7.3",
"symfony/webpack-encore-bundle": "^2.2",
"willdurand/negotiation": "^3.1"
},
"prefer-stable": true,
Expand All @@ -67,18 +65,19 @@
},
"autoload-dev": {
"psr-4": {
"Setono\\SyliusTermsPlugin\\Tests\\": "tests/"
},
"classmap": [
"tests/Application/Kernel.php"
]
"Setono\\SyliusTermsPlugin\\Tests\\": "tests/",
"Tests\\Setono\\SyliusTermsPlugin\\": "tests/TestApplication/src"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false,
"ergebnis/composer-normalize": true,
"infection/extension-installer": true,
"symfony/thanks": false
"php-http/discovery": true,
"symfony/thanks": false,
"symfony/runtime": true,
"symfony/flex": true
},
"sort-packages": true
},
Expand All @@ -87,5 +86,8 @@
"check-style": "ecs check",
"fix-style": "ecs check --fix",
"phpunit": "phpunit"
},
"extra": {
"public-dir": "vendor/sylius/test-application/public"
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imports:
- { resource: "app/fixtures.yaml" }
- { resource: "twig_hooks/**/*.yaml" }
4 changes: 2 additions & 2 deletions src/Resources/config/routes.yaml β†’ config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
setono_sylius_terms_shop:
resource: "@SetonoSyliusTermsPlugin/Resources/config/routes/shop.yaml"
resource: "@SetonoSyliusTermsPlugin/config/routes/shop.yaml"
prefix: /{_locale}
requirements:
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$

setono_sylius_terms_admin:
resource: "@SetonoSyliusTermsPlugin/Resources/config/routes/admin.yaml"
resource: "@SetonoSyliusTermsPlugin/config/routes/admin.yaml"
prefix: /admin
12 changes: 12 additions & 0 deletions config/routes/admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
setono_sylius_terms_admin_terms:
resource: |
alias: setono_sylius_terms.terms
section: admin
except: [show]
templates: "@SyliusAdmin\\shared\\crud"
redirect: update
grid: setono_sylius_terms_terms
vars:
all:
hook_prefix: 'setono_sylius_terms.admin.terms'
type: sylius.resource
File renamed without changes.
6 changes: 6 additions & 0 deletions config/routes_no_locale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
setono_sylius_terms_shop:
resource: "@SetonoSyliusTermsPlugin/config/routes/shop.yaml"

setono_sylius_terms_admin:
resource: "@SetonoSyliusTermsPlugin/config/routes/admin.yaml"
prefix: /admin
Loading