diff --git a/.github/workflows/phpcompatibility.yml b/.github/workflows/phpcompatibility.yml
new file mode 100644
index 0000000..655d94c
--- /dev/null
+++ b/.github/workflows/phpcompatibility.yml
@@ -0,0 +1,9 @@
+name: PHPCompatibility
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: 7.0-7.1
+ run: docker run --rm -v $PWD:/code domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0-7.1 --colors --ignore=./Test/ ./
diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml
new file mode 100644
index 0000000..9787dcd
--- /dev/null
+++ b/.github/workflows/phpcs.yml
@@ -0,0 +1,9 @@
+name: phpcs
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: Magento 2 Ruleset
+ run: docker run --rm -v $PWD:/code domw/phpcs phpcs --colors --standard=Magento2 ./
diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml
new file mode 100644
index 0000000..a228d9d
--- /dev/null
+++ b/.github/workflows/phpcsfixer.yml
@@ -0,0 +1,9 @@
+name: php-cs-fixer
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - name: PHP CS Fixer
+ run: docker run --rm -v $PWD:/code domw/php-cs-fixer php-cs-fixer fix --dry-run --diff --stop-on-violation --allow-risky=yes ./
diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml
new file mode 100644
index 0000000..784dece
--- /dev/null
+++ b/.github/workflows/phpstan.yml
@@ -0,0 +1,15 @@
+name: PHPStan
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - uses: MilesChou/composer-action@master
+ with:
+ args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
+ - uses: MilesChou/composer-action@master
+ with:
+ args: install --prefer-dist --ignore-platform-reqs
+ - name: PHPStan
+ run: docker run --rm -v $PWD:/code domw/phpstan phpstan analyze ./
\ No newline at end of file
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
new file mode 100644
index 0000000..d771277
--- /dev/null
+++ b/.github/workflows/phpunit.yml
@@ -0,0 +1,15 @@
+name: PHPUnit
+on: ["push", "pull_request"]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - uses: MilesChou/composer-action@master
+ with:
+ args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
+ - uses: MilesChou/composer-action@master
+ with:
+ args: install --prefer-dist --ignore-platform-reqs
+ - name: PHPUnit
+ run: vendor/bin/phpunit -c Test/phpunit.xml Test/
diff --git a/.github/workflows/xmllint.yml b/.github/workflows/xmllint.yml
new file mode 100644
index 0000000..09f192b
--- /dev/null
+++ b/.github/workflows/xmllint.yml
@@ -0,0 +1,23 @@
+name: xmllint
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@master
+ - uses: MilesChou/composer-action@master
+ with:
+ args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
+ - uses: MilesChou/composer-action@master
+ with:
+ args: install --prefer-dist --ignore-platform-reqs
+ - name: XML Lint
+ run: |
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/config.xml --schema ./vendor/magento/module-store/etc/config.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/menu.xml --schema ./vendor/magento/module-backend/etc/menu.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/routes.xml --schema ./vendor/magento/framework/App/etc/routes.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/system.xml --schema vendor/magento/module-config/etc/system.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/acl.xml --schema ./vendor/magento/framework/Acl/etc/acl.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/cron_groups.xml --schema ./vendor/magento/module-cron/etc/cron_groups.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/crontab.xml --schema ./vendor/magento/module-cron/etc/crontab.xsd
+ docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/module.xml --schema ./vendor/magento/framework/Module/etc/module.xsd
diff --git a/Makefile b/Makefile
index a8140fe..ad3d293 100644
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,10 @@ checkstyle:
checkquality:
vendor/bin/phpstan analyse
+ xmllint --noout --schema vendor/magento/module-store/etc/config.xsd etc/config.xml
xmllint --noout --schema vendor/magento/module-backend/etc/menu.xsd etc/adminhtml/menu.xml
xmllint --noout --schema vendor/magento/framework/App/etc/routes.xsd etc/adminhtml/routes.xml
+ xmllint --noout --schema vendor/magento/module-config/etc/system.xsd etc/adminhtml/system.xml
xmllint --noout --schema vendor/magento/framework/Acl/etc/acl.xsd etc/acl.xml
xmllint --noout --schema vendor/magento/module-cron/etc/cron_groups.xsd etc/cron_groups.xml
xmllint --noout --schema vendor/magento/module-cron/etc/crontab.xsd etc/crontab.xml
diff --git a/Storage/FileStorage.php b/Storage/FileStorage.php
index fd62678..9650d0f 100644
--- a/Storage/FileStorage.php
+++ b/Storage/FileStorage.php
@@ -5,23 +5,30 @@
namespace Baldwin\UrlDataIntegrityChecker\Storage;
use Baldwin\UrlDataIntegrityChecker\Exception\SerializationException;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
class FileStorage extends AbstractStorage implements StorageInterface
{
+ const CONFIG_PATH = 'url/checker/path';
+
private $filesystem;
+ private $scopeConfig;
public function __construct(
- Filesystem $filesystem
+ Filesystem $filesystem,
+ ScopeConfigInterface $scopeConfig
) {
$this->filesystem = $filesystem;
+ $this->scopeConfig = $scopeConfig;
}
public function write(string $identifier, array $data): bool
{
- $directory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
+ $directory = $this->filesystem->getDirectoryWrite($this->getPath() ?: DirectoryList::TMP);
$directory->create();
$filename = $this->getFilename($identifier);
@@ -39,7 +46,7 @@ public function write(string $identifier, array $data): bool
public function read(string $identifier): array
{
- $directory = $this->filesystem->getDirectoryRead(DirectoryList::TMP);
+ $directory = $this->filesystem->getDirectoryRead($this->getPath() ?: DirectoryList::TMP);
$filename = $this->getFilename($identifier);
$data = '';
@@ -57,4 +64,12 @@ private function getFilename(string $identifier): string
{
return 'baldwin-url-data-integrity-checker-' . $identifier . '.json';
}
+
+ private function getPath(): string
+ {
+ return $this->scopeConfig->getValue(
+ self::CONFIG_PATH,
+ ScopeInterface::SCOPE_STORE
+ );
+ }
}
diff --git a/etc/acl.xml b/etc/acl.xml
index 7359fe4..55694a1 100644
--- a/etc/acl.xml
+++ b/etc/acl.xml
@@ -6,6 +6,13 @@
+
+
+
+
+
+
+
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
new file mode 100644
index 0000000..abdac4b
--- /dev/null
+++ b/etc/adminhtml/system.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+ baldwin
+ Baldwin_UrlDataIntegrityChecker::config_baldwin_urldataintegritychecker
+
+
+
+
+ Path where to store json files eg tmp or media
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/config.xml b/etc/config.xml
new file mode 100644
index 0000000..96629ec
--- /dev/null
+++ b/etc/config.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ tmp
+
+
+
+
\ No newline at end of file
diff --git a/phpstan.neon b/phpstan.neon
index d2755cc..75e69ef 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,20 +1,11 @@
parameters:
level: max
- inferPrivatePropertyTypeFromConstructor: true
- paths:
- - .
- bootstrapFiles:
- - vendor/bitexpert/phpstan-magento/autoload.php
excludes_analyse:
- - %currentWorkingDirectory%/vendor/*
+ - 'vendor'
ignoreErrors:
- - '/ has no return typehint specified./'
-
- - message: '/Use service contracts to persist entities in favour of Magento\\Cron\\Model\\Schedule\:\:save\(\) method/'
- path: Cron/ScheduleJob.php
-
- - message: '/Call to deprecated method save\(\) of class Magento\\Framework\\Model\\AbstractModel/'
- path: Cron/ScheduleJob.php
-
- - message: '/Parameter \#1 \$autoload_function of function spl_autoload_register expects callable\(string\)\: void, array\(Magento\\Framework\\TestFramework\\Unit\\Autoloader\\GeneratedClassesAutoloader/'
- path: Test/bootstrap.php
+ - '#typehint#'
+ - '#Factory#'
+ - '#Use service contracts to persist entities#'
+ - '#Call to deprecated method save#'
+ - '#Parameter \#1 \$autoload_function of function spl_autoload_register#'
+ reportUnmatchedIgnoredErrors: false
\ No newline at end of file