Skip to content

Commit

Permalink
Merge pull request #41 from synolia/feature/fix-documentation
Browse files Browse the repository at this point in the history
Fix document and add prefix to routes
  • Loading branch information
oallain authored Jul 19, 2022
2 parents 29297f3 + 820d414 commit c476b45
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 80 deletions.
50 changes: 33 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ on:
- README.md

jobs:
php:

analysis:
name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony }}
runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
symfony: [4.4.*, 5.2.*]
symfony: [4.4.*, 5.4.*]

env:
APP_ENV: test

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -48,6 +52,9 @@ jobs:
- name: Composer - Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}

- name: Composer - Allow all plugins
run: composer config allow-plugins true

- name: Composer - Restrict Symfony version
run: composer config extra.symfony.require "${{ matrix.symfony }}"

Expand All @@ -56,42 +63,47 @@ jobs:
id: end-of-setup

- name: ECS - Run
run: if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check --no-progress-bar -c ruleset/ecs.php ; else echo Ecs rulesets file does not exist, skipping step ; fi
run: if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check src/ --no-progress-bar -c ruleset/ecs.php ; else echo Ecs ruleset file does not exist, skipping step ; fi
if: always() && steps.end-of-setup.outcome == 'success'

- name: PHPStan - Run
run: if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon src/ ; else echo PHPStan rulesets file does not exist, skipping step ; fi
run: if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon src/ ; else echo PHPStan ruleset file does not exist, skipping step ; fi
if: always() && steps.end-of-setup.outcome == 'success'

- name: PHPSpec - Run
run: if [ -f phpspec.yml.dist ]; then vendor/bin/phpspec run ; else echo PHPSpec config file does not exist, skipping step ; fi
if: always() && steps.end-of-setup.outcome == 'success'

- name: PHPMD - Run
run: if [ -f ruleset/.php_md.xml ]; then vendor/bin/phpmd src ansi ruleset/.php_md.xml ; else echo PHPMD config file does not exist, skipping step ; fi
if: always() && steps.end-of-setup.outcome == 'success'

- name: GrumPHP - Run
run: (test -f grumphp.yml && vendor/bin/grumphp run) || echo Grumphp ruleset file does not exist, skipping step
run: if [ -f grumphp.yml ]; then vendor/bin/grumphp run ; else echo Grumphp ruleset file does not exist, skipping step ; fi
if: always() && steps.end-of-setup.outcome == 'success'

- name: Checks security issues - Run
run: symfony security:check
- uses: symfonycorp/security-checker-action@v3
if: always() && steps.end-of-setup.outcome == 'success'

sylius:
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
name: PHPUnit-Behat (PHP ${{ matrix.php }} Sylius ${{ matrix.sylius }} Symfony ${{ matrix.symfony }})
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
sylius: [1.10.0, 1.11.0]
symfony: [4.4, 5.2]
sylius: [1.9.0, 1.10.0, 1.11.0]
symfony: [4.4, 5.4]
node: [10.x]
exclude:
- sylius: 1.10.0
symfony: 4.4
- sylius: 1.11.0
symfony: 4.4
- sylius: 1.11.0
php: 7.4
- sylius: 1.9.0
php: 8.0
- sylius: 1.9.0
php: 8.1
- sylius: 1.11.0
symfony: 4.4
- sylius: 1.11.0
php: 7.4

env:
APP_ENV: test
Expand Down Expand Up @@ -146,7 +158,11 @@ jobs:
node-${{ matrix.node }}-yarn-
- name: Install Sylius-Standard and Plugin
run: make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }}
run: make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }} PHP_VERSION=${{ matrix.php }}

- name: Doctrine Schema Validate - Run
working-directory: ./tests/Application
run: php bin/console doctrine:schema:validate --skip-sync

- name: Run PHPUnit
run: make phpunit
Expand Down
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
SHELL=/bin/bash
COMPOSER_ROOT=composer
TEST_DIRECTORY=tests/Application
CONSOLE=cd tests/Application && bin/console
CONSOLE=cd tests/Application && php bin/console -e test
COMPOSER=cd tests/Application && composer
YARN=cd tests/Application && yarn

SYLIUS_VERSION=1.10.0
SYMFONY_VERSION=5.2
SYLIUS_VERSION=1.11.0
SYMFONY_VERSION=5.4
PHP_VERSION=8.0
PLUGIN_NAME=synolia/sylius-gdpr-plugin

###
### DEVELOPMENT
### ¯¯¯¯¯¯¯¯¯¯¯

install: sylius ## Install Plugin on Sylius [SyliusVersion=1.9] [SymfonyVersion=5.2]
install: sylius ## Install Plugin on Sylius [SyliusVersion=1.11] [SymfonyVersion=5.4] [PHP_VERSION=8.0]
.PHONY: install

reset: ## Remove dependencies
ifneq ("$(wildcard tests/Application/bin/console)","")
${CONSOLE} doctrine:database:drop --force --if-exists || true
endif
rm -rf tests/Application
.PHONY: reset

Expand All @@ -28,26 +32,30 @@ phpunit: phpunit-configure phpunit-run ## Run PHPUnit
### OTHER
### ¯¯¯¯¯¯

sylius: sylius-standard install-plugin restrict-symfony-version install-sylius
sylius: sylius-standard update-dependencies install-plugin install-sylius
.PHONY: sylius

sylius-standard:
${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}"
${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}" --no-install --no-scripts
${COMPOSER} config allow-plugins true
${COMPOSER} require sylius/sylius:"~${SYLIUS_VERSION}"

update-dependencies:
${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}"
${COMPOSER} require symfony/asset:^${SYMFONY_VERSION} --no-scripts --no-update
ifeq ($(SYLIUS_VERSION), 1.9.0)
${COMPOSER} require laminas/laminas-stdlib:3.4.0 --no-scripts --no-update
endif
${COMPOSER} update --no-progress -n

install-plugin:
${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}'
${COMPOSER} config extra.symfony.allow-contrib true
${COMPOSER} config minimum-stability "dev"
${COMPOSER} config prefer-stable true
${COMPOSER} req "${PLUGIN_NAME}:*" --prefer-source --no-scripts
${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts
cp -r install/Application tests

restrict-symfony-version:
${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}"
ifeq ($(SYMFONY_VERSION), 4.4)
${COMPOSER} require sylius/admin-api-bundle --no-scripts --no-update
endif
${COMPOSER} update --no-progress -n
cp -r tests/data/* ${TEST_DIRECTORY}/

install-sylius:
${CONSOLE} sylius:install -n -s default
Expand All @@ -57,12 +65,11 @@ install-sylius:

phpunit-configure:
cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml
cp -r tests/data/* ${TEST_DIRECTORY}/

phpunit-run:
cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit

grumphp:
grumphp: ## Run GrumPHP
vendor/bin/grumphp run

help: SHELL=/bin/bash
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@
And
```yaml
synolia_gdpr:
synolia_gdpr_controller:
resource: "@SynoliaSyliusGDPRPlugin/Resources/config/routes/admin/gdpr.yaml"
prefix: '/%sylius_admin.path_name%'
prefix: '%sylius_admin.path_name%/gdpr/'
name_prefix: 'sylius_gdpr_'
```
Or you can add this conf file, which will import the entire route configuration
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"phpunit/phpunit": "^9.5",
"povils/phpmnd": "^2.5",
"seld/jsonlint": "^1.7",
"sylius-labs/coding-standard": "^v4.0",
"symplify/easy-coding-standard": "^9.4.70",
"sylius-labs/coding-standard": "4.1.*",
"symplify/easy-coding-standard": "9.4.70",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
Expand Down
7 changes: 4 additions & 3 deletions install/Application/config/routes/gdpr.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
synolia_gdpr:
resource: "@SynoliaSyliusGDPRPlugin/Resources/config/routes/admin/customer.yaml"
prefix: '/%sylius_admin.path_name%'
synolia_gdpr_controller:
resource: "@SynoliaSyliusGDPRPlugin/Resources/config/routes/admin/gdpr.yaml"
prefix: '%sylius_admin.path_name%/gdpr/'
name_prefix: 'sylius_gdpr_'
2 changes: 1 addition & 1 deletion src/Command/AnonymizeProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function anonymizeEntityForClassName(string $className, ?string $id = nu
if (false === $force) {
$response = $this->io->confirm(
'Are you sure to anonymize this entity (' . $className . ') ? Data will be changed without back-up.',
false
false,
);
if (true !== $response) {
throw new \LogicException('No data has been changed.');
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/AdvancedActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __invoke(Request $request): Response
$this->generateAndProcessFormsType($request, self::FORMS),
$this->generateAndProcessFormsType(
$request,
$this->formsType
)
$this->formsType,
),
);

return $this->render('@SynoliaSyliusGDPRPlugin\Gdpr\Actions.html.twig', ['forms' => $formViews]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ExportDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __invoke(string $id): Response
$response = new Response($formattedCustomerData);
$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
$fileName . '.json'
$fileName . '.json',
);

$response->headers->set('Content-Disposition', $disposition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()
'synolia.gdpr_processing.advanced_actions_form_data_processor',
'Synolia\SyliusGDPRPlugin\Processor\AdvancedActions\CompositeAdvancedActionsFormDataProcessor',
self::PROCESSOR_SERVICE_TAG,
'addProcessor'
'addProcessor',
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function process(ContainerBuilder $container): void
if (ArrayLoader::class === $definition->getClass()) {
$definition->setArgument(
0,
$container->getParameter('synolia_anonymization_mapping')
$container->getParameter('synolia_anonymization_mapping'),
);
}
$chainLoader->addMethodCall('addLoader', [new Reference($id)]);
Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/SynoliaSyliusGDPRExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('services.yaml');

$container->registerForAutoconfiguration(LoaderInterface::class)
->addTag('anonymization_loader');
->addTag('anonymization_loader')
;
$mapping = $this->retrieveMappings($configs, $config['disable_default_mappings']);

$container->setParameter('synolia_anonymization_mapping', $mapping);
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/AnnotationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function loadClassMetadata(string $className): AttributeMetadataCollectio
foreach ($properties as $property) {
$annotation = $this->annotationReader->getPropertyAnnotation(
$property,
Anonymize::class
Anonymize::class,
);

if (!$annotation instanceof Anonymize) {
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function loadClassMetadata(string $className): AttributeMetadataCollectio
$attributeMetaDataCollection = $this->assignAttributeMetaDataCollection(
$mapping,
$realClassName,
$attributeMetaDataCollection
$attributeMetaDataCollection,
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Menu/GDPRMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function addGDPRMenuItems(MenuBuilderEvent $event): void
$gdprMenu
->addChild('sylius.ui.admin.synolia_gdpr.advanced_actions.title', [
'route' => 'sylius_gdpr_advanced_actions',
]);
])
;
}
}
Loading

0 comments on commit c476b45

Please sign in to comment.