-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a113904
Showing
82 changed files
with
1,977 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[**.{yml,yaml,yml.dist}] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
/vendor/ | ||
/node_modules/ | ||
/composer.lock | ||
|
||
/etc/build/* | ||
!/etc/build/.gitkeep | ||
|
||
/tests/Application/yarn.lock | ||
|
||
docker-compose.override.yaml | ||
docker-compose.override.dist.yaml | ||
docker-compose.yaml | ||
/bin-docker/ | ||
/deploy/ | ||
/docker/ | ||
/etc/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
language: php | ||
|
||
dist: trusty | ||
|
||
sudo: false | ||
|
||
php: | ||
- 7.2 | ||
|
||
cache: | ||
yarn: true | ||
directories: | ||
- ~/.composer/cache/files | ||
- $SYLIUS_CACHE_DIR | ||
|
||
env: | ||
global: | ||
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache | ||
- SYLIUS_BUILD_DIR=etc/build | ||
matrix: | ||
- SYMFONY_VERSION="3.4.*" | ||
- SYMFONY_VERSION="4.1.*" | ||
|
||
before_install: | ||
- phpenv config-rm xdebug.ini | ||
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
- mkdir -p "${SYLIUS_CACHE_DIR}" | ||
|
||
install: | ||
- composer require "symfony/symfony:${SYMFONY_VERSION}" --no-interaction --no-update | ||
- composer install --no-interaction --prefer-dist | ||
- (cd tests/Application && yarn install) | ||
|
||
before_script: | ||
- (cd tests/Application && bin/console doctrine:database:create --env=test -vvv) | ||
- (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv) | ||
- (cd tests/Application && bin/console assets:install web --env=test -vvv) | ||
- (cd tests/Application && bin/console cache:warmup --env=test -vvv) | ||
- (cd tests/Application && yarn build) | ||
|
||
# Configure display | ||
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16 | ||
- export DISPLAY=:99 | ||
|
||
# Download and configure ChromeDriver | ||
- | | ||
if [ ! -f $SYLIUS_CACHE_DIR/chromedriver ] || [ "$($SYLIUS_CACHE_DIR/chromedriver --version | grep -c 2.34)" = "0" ]; then | ||
curl http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip > chromedriver.zip | ||
unzip chromedriver.zip | ||
chmod +x chromedriver | ||
mv chromedriver $SYLIUS_CACHE_DIR | ||
fi | ||
# Run ChromeDriver | ||
- $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 & | ||
|
||
# Download and configure Selenium | ||
- | | ||
if [ ! -f $SYLIUS_CACHE_DIR/selenium.jar ] || [ "$(java -jar $SYLIUS_CACHE_DIR/selenium.jar --version | grep -c 3.4.0)" = "0" ]; then | ||
curl http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar > selenium.jar | ||
mv selenium.jar $SYLIUS_CACHE_DIR | ||
fi | ||
# Run Selenium | ||
- java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 & | ||
|
||
# Run webserver | ||
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web --env=test --quiet > /dev/null 2>&1 &) | ||
|
||
script: | ||
- composer validate --strict | ||
- bin/phpstan.phar analyse -c phpstan.neon -l max src/ | ||
|
||
- bin/phpunit | ||
- bin/phpspec run | ||
- bin/behat --strict -vvv --no-interaction || bin/behat --strict -vvv --no-interaction --rerun | ||
|
||
after_failure: | ||
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<p align="center"> | ||
<a href="https://www.mangoweb.cz/en/" target="_blank"> | ||
<img src="https://avatars0.githubusercontent.com/u/38423357?s=200&v=4"/> | ||
</a> | ||
</p> | ||
<h1 align="center">Payment Restrictions Plugin</h1> | ||
|
||
## Features | ||
|
||
xxxx | ||
|
||
## Installation | ||
|
||
1. Run `$ composer require mangoweb-sylius/sylius-payment-restrictions-plugin`. | ||
2. Register `\MangoSylius\PaymentRestrictionPlugin\MangoSyliusPaymentRestrictionPlugin` in your Kernel. | ||
3. Your Entity `PaymentMethod` has to implement `\MangoSylius\PaymentRestrictionPlugin\Model\PaymentMethodRestrictionInterface`. You can use Trait `MangoSylius\PaymentRestrictionPlugin\Model\PaymentMethodRestrictionTrait`. | ||
4. Add `{{ form_row(form.zone) }}` to `@SyliusAdmin/PaymentMethod/_form.html.twig`. | ||
|
||
For guide to use your own entity see [Sylius docs - Customizing Models](https://docs.sylius.com/en/1.3/customization/model.html) | ||
|
||
## Development | ||
|
||
### Usage | ||
|
||
- Create symlink from .env.dist to .env or create your own .env file | ||
- Develop your plugin in `/src` | ||
- See `bin/` for useful commands | ||
|
||
### Testing | ||
|
||
After your changes you must ensure that the tests are still passing. | ||
* Easy Coding Standard | ||
```bash | ||
bin/ecs.sh | ||
``` | ||
* PHPStan | ||
```bash | ||
bin/phpstan.sh | ||
``` | ||
License | ||
------- | ||
This library is under the MIT license. | ||
|
||
Credits | ||
------- | ||
Developed by [manGoweb](https://www.mangoweb.eu/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
imports: | ||
- vendor/sylius/sylius/behat.yml.dist | ||
- tests/Behat/Resources/suites.yml | ||
|
||
default: | ||
extensions: | ||
FriendsOfBehat\ContextServiceExtension: | ||
imports: | ||
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml | ||
- tests/Behat/Resources/services.xml | ||
|
||
FriendsOfBehat\SymfonyExtension: | ||
kernel: | ||
class: \App\Kernel | ||
path: tests/Application/src/Kernel.php | ||
bootstrap: vendor/autoload.php | ||
|
||
Lakion\Behat\MinkDebugExtension: | ||
directory: etc/build | ||
clean_start: false | ||
screenshot: true | ||
|
||
Behat\MinkExtension: | ||
base_url: "http://nginx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../vendor/bin/behat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../tests/Application/bin/console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# project root | ||
cd "$(dirname "$DIR")" | ||
|
||
set -x | ||
|
||
rm -rf tests/Application/var/cache/ | ||
vendor/bin/ecs check src tests "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# project root | ||
cd "$(dirname "$DIR")" | ||
|
||
set -x | ||
tests/Application/bin/console --env=dev cache:warmup | ||
vendor/bin/phpstan analyse \ | ||
--level 7 \ | ||
--memory-limit 1G \ | ||
--configuration phpstan.neon \ | ||
src tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "mangoweb-sylius/sylius-payment-restrictions-plugin", | ||
"type": "sylius-plugin", | ||
"description": "Payment restriction plugin for Sylius", | ||
"license": "MIT", | ||
"require": { | ||
"php": "^7.1", | ||
"sylius/sylius": "^1.2.5", | ||
"symfony/symfony": "^4.1" | ||
}, | ||
"require-dev": { | ||
"behat/behat": "^3.4", | ||
"behat/mink": "^1.7@dev", | ||
"behat/mink-browserkit-driver": "^1.3", | ||
"behat/mink-extension": "^2.2", | ||
"behat/mink-selenium2-driver": "^1.3", | ||
"friends-of-behat/context-service-extension": "^1.2", | ||
"friends-of-behat/cross-container-extension": "^1.1", | ||
"friends-of-behat/service-container-extension": "^1.0", | ||
"friends-of-behat/symfony-extension": "^1.2.1", | ||
"friends-of-behat/variadic-extension": "^1.1", | ||
"lakion/mink-debug-extension": "^1.2.3", | ||
"phpstan/phpstan-doctrine": "^0.10", | ||
"phpstan/phpstan-shim": "^0.10", | ||
"phpstan/phpstan-symfony": "^0.10", | ||
"phpstan/phpstan-webmozart-assert": "^0.10", | ||
"phpunit/phpunit": "^6.5", | ||
"sylius-labs/coding-standard": "^2.0", | ||
"se/selenium-server-standalone": "^3.12" | ||
}, | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"MangoSylius\\PaymentRestrictionPlugin\\": "src/", | ||
"Tests\\MangoSylius\\PaymentRestrictionPlugin\\": "tests/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"App\\": "tests/Application/src/" | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
imports: | ||
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' } | ||
|
||
parameters: | ||
indentation: tab | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/Application/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-doctrine/extension.neon | ||
- vendor/phpstan/phpstan-symfony/extension.neon | ||
- vendor/phpstan/phpstan-webmozart-assert/extension.neon | ||
|
||
parameters: | ||
symfony: | ||
container_xml_path: tests/Application/var/cache/dev/srcApp_KernelDevDebugContainer.xml | ||
|
||
excludes_analyse: | ||
# Too slow | ||
- 'src/DependencyInjection/Configuration.php' | ||
|
||
# Test dependencies | ||
- '*/tests/Application/var/*' | ||
|
||
- '*/tests/Behat/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.6/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="AcmeSyliusExamplePlugin Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<php> | ||
<server name="KERNEL_CLASS_PATH" value="/tests/Application/src/Kernel.php" /> | ||
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" /> | ||
</php> | ||
</phpunit> |
19 changes: 19 additions & 0 deletions
19
src/DependencyInjection/MangoSyliusPaymentRestrictionExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MangoSylius\PaymentRestrictionPlugin\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
class MangoSyliusPaymentRestrictionExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MangoSylius\PaymentRestrictionPlugin\Form\Extension; | ||
|
||
use Sylius\Bundle\AddressingBundle\Form\Type\ZoneChoiceType; | ||
use Sylius\Bundle\PaymentBundle\Form\Type\PaymentMethodType; | ||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
final class RestrictionPaymentMethodExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('zone', ZoneChoiceType::class, [ | ||
'label' => 'sylius.form.address.zone', | ||
'constraints' => [ | ||
new NotBlank(['groups' => ['sylius']]), | ||
], | ||
]); | ||
} | ||
|
||
public function getExtendedType(): string | ||
{ | ||
return PaymentMethodType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MangoSylius\PaymentRestrictionPlugin; | ||
|
||
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class MangoSyliusPaymentRestrictionPlugin extends Bundle | ||
{ | ||
use SyliusPluginTrait; | ||
} |
Oops, something went wrong.