diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index b4ce86f..2b5177c 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,12 +1,16 @@ name-template: v$NEXT_PATCH_VERSION tag-template: v$NEXT_PATCH_VERSION categories: - - title: 🚀 Improvements + - title: 🔨 Improvements label: enhancement - title: 🐛 Bug Fixes label: bug + - title: 🚀 New Features + label: Feature change-template: '- #$NUMBER: $TITLE by @$AUTHOR' template: | # Changes $CHANGES + + diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..ce9a82b --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,61 @@ +name: Build & Release draft + +on: + pull_request: + push: + branches: + - master + +jobs: + deploy: + name: build dependencies & create artifact + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Install composer dependencies + run: composer install --no-dev -o + - name: Clean-up project + uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0 + - name: Create & upload artifact + uses: actions/upload-artifact@v1 + with: + name: ${{ github.event.repository.name }} + path: ../ + update_release_draft: + runs-on: ubuntu-latest + needs: [deploy] + if: github.event_name == 'push' + steps: + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: ${{ github.event.repository.name }} + - id: release_info + uses: toolmantim/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Prepare for Release + run: | + cd ${{ github.event.repository.name }} + zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} + - name: Clean existing assets + shell: bash + run: | + curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 + assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'` + for asset in $assets + do + bin/hub api -X DELETE $asset + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to GitHub Release + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_info.outputs.upload_url }} + asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip + asset_name: ${{ github.event.repository.name }}.zip + asset_content_type: application/zip diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..f5dc3b6 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,52 @@ +name: PHP tests +on: [push, pull_request] +jobs: + php-linter: + name: PHP Syntax check 5.6|7.2|7.3 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: PHP syntax checker 5.6 + uses: prestashop/github-action-php-lint/5.6@master + - name: PHP syntax checker 7.2 + uses: prestashop/github-action-php-lint/7.2@master + - name: PHP syntax checker 7.3 + uses: prestashop/github-action-php-lint/7.3@master + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Run PHP-CS-Fixer + uses: prestashopcorp/github-action-php-cs-fixer@master + phpstan: + name: PHPStan + runs-on: ubuntu-latest + strategy: + matrix: + presta-versions: ['1.7.0.3', 'latest'] + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + + - name: Cache vendor folder + uses: actions/cache@v1 + with: + path: vendor + key: php-${{ hashFiles('composer.lock') }} + + - name: Cache composer folder + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: php-composer-cache + + - run: composer install + + - name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }}) + run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }} + + - name : Run PHPStan + run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/phpstan.neon diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..9830d6d --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,11 @@ +setUsingCache(true) + ->getFinder() + ->in(__DIR__) + ->exclude('vendor'); + +return $config; diff --git a/composer.json b/composer.json index 5c04099..8e460de 100644 --- a/composer.json +++ b/composer.json @@ -1,23 +1,41 @@ { - "name": "matt75/displayordercarrier", - "description": "PrestaShop module displayordercarrier", - "homepage": "https://github.com/Matt75/displayordercarrier", - "license": "AFL-3.0", - "authors": [ - { - "name": "Matt75", - "email": "matthias.raigne@prestashop.com" - } - ], - "require": { - "php": ">=5.6" - }, - "config": { - "platform": { - "php": "5.6.0" + "type": "prestashop-module", + "name": "matt75/displayordercarrier", + "description": "PrestaShop module displayordercarrier", + "homepage": "https://github.com/Matt75/displayordercarrier", + "license": "AFL-3.0", + "authors": [ + { + "name": "Matt75", + "email": "matthias.raigne@prestashop.com" + } + ], + "config": { + "platform": { + "php": "5.6.0" + }, + "preferred-install": "dist", + "classmap-authoritative": true, + "optimize-autoloader": true, + "sort-packages": true, + "prepend-autoloader": false }, - "preferred-install": "dist", - "prepend-autoloader": false - }, - "type": "prestashop-module" -} + "autoload": { + "psr-4": { + "PrestaShop\\Module\\DisplayOrderCarrier\\": "src/" + }, + "classmap": [ + "controllers", + "displayordercarrier.php" + ] + }, + "scripts": { + "set-license-header": [ + "@php ./vendor/bin/header-stamp --license=\"assets/afl.txt\" --exclude=\".github,node_modules,vendor\"" + ] + }, + "require-dev": { + "prestashop/php-dev-tools": "^3.4" + }, + "author": "PrestaShop" +} \ No newline at end of file diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..e0a24e8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1367 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "5d04bc6ff819b62af16bdb8876c0851f", + "packages": [], + "packages-dev": [ + { + "name": "composer/semver", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2020-01-13T12:06:48+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2020-06-04T11:16:35+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-02-24T16:22:25+00:00" + }, + { + "name": "doctrine/lexer", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "time": "2019-06-08T11:03:04+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.16.4", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/1023c3458137ab052f6ff1e09621a721bfdeca13", + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.2", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^5.1", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/Test/IsIdenticalConstraint.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2020-06-27T23:57:46+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2018-02-28T20:30:58+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v2.0.18", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2019-01-03T20:59:08+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, + { + "name": "prestashop/header-stamp", + "version": "v1.5", + "source": { + "type": "git", + "url": "https://github.com/PrestaShopCorp/header-stamp.git", + "reference": "3bbeb8096097920ca862e1363ef4a43542392085" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PrestaShopCorp/header-stamp/zipball/3bbeb8096097920ca862e1363ef4a43542392085", + "reference": "3bbeb8096097920ca862e1363ef4a43542392085", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^3.1", + "php": ">=5.6", + "symfony/console": "^3.4 || ~4.0 || ~5.0", + "symfony/finder": "^3.4 || ~4.0 || ~5.0" + }, + "require-dev": { + "prestashop/php-dev-tools": "1.*" + }, + "bin": [ + "bin/header-stamp" + ], + "type": "library", + "autoload": { + "psr-4": { + "PrestaShop\\HeaderStamp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AFL-3.0" + ], + "authors": [ + { + "name": "PrestaShop SA", + "email": "contact@prestashop.com" + } + ], + "description": "Rewrite your file headers to add the license or to make them up-to-date", + "homepage": "https://github.com/PrestaShopCorp/header-stamp", + "time": "2020-07-15T14:52:12+00:00" + }, + { + "name": "prestashop/php-dev-tools", + "version": "v3.8", + "source": { + "type": "git", + "url": "https://github.com/PrestaShop/php-dev-tools.git", + "reference": "6e799a01119d838beaf6466d349f3c77b9fc462d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PrestaShop/php-dev-tools/zipball/6e799a01119d838beaf6466d349f3c77b9fc462d", + "reference": "6e799a01119d838beaf6466d349f3c77b9fc462d", + "shasum": "" + }, + "require": { + "friendsofphp/php-cs-fixer": "^2.14", + "php": ">=5.6.0", + "prestashop/header-stamp": "^1.0", + "squizlabs/php_codesniffer": "^3.4", + "symfony/console": "~3.2 || ~4.0 || ~5.0", + "symfony/filesystem": "~3.2 || ~4.0 || ~5.0" + }, + "bin": [ + "bin/prestashop-coding-standards" + ], + "type": "library", + "autoload": { + "psr-4": { + "PrestaShop\\CodingStandards\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PrestaShop coding standards", + "time": "2020-07-19T14:47:58+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.5", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-04-17T01:09:41+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "afc7189694d2c59546cf24ea606a236fa46a966e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/afc7189694d2c59546cf24ea606a236fa46a966e", + "reference": "afc7189694d2c59546cf24ea606a236fa46a966e", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2020-07-06T08:57:31+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "7ce874f4432d8b11cc45a80cc5130a6e2609728d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/7ce874f4432d8b11cc45a80cc5130a6e2609728d", + "reference": "7ce874f4432d8b11cc45a80cc5130a6e2609728d", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2020-07-16T09:41:49+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/14d978f8e8555f2de719c00eb65376be7d2e9081", + "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2020-05-05T15:06:23+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f625d0cb1e59c8c4ba61abb170125175218ff10", + "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2020-05-30T17:48:24+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "5ec813ccafa8164ef21757e8c725d3a57da59200" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/5ec813ccafa8164ef21757e8c725d3a57da59200", + "reference": "5ec813ccafa8164ef21757e8c725d3a57da59200", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2020-02-14T07:34:21+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "0edf31d2e34f4adb72dd4d2e4a8aa21f84b943e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0edf31d2e34f4adb72dd4d2e4a8aa21f84b943e5", + "reference": "0edf31d2e34f4adb72dd4d2e4a8aa21f84b943e5", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2020-07-08T17:07:26+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", + "reference": "0dd93f2c578bdc9c72697eaa5f1dd25644e618d3", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "639447d008615574653fb3bc60d1986d7172eaae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae", + "reference": "639447d008615574653fb3bc60d1986d7172eaae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/process", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "af8d812d75fcdf2eae30928b42396fe17df137e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/af8d812d75fcdf2eae30928b42396fe17df137e4", + "reference": "af8d812d75fcdf2eae30928b42396fe17df137e4", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2020-07-16T09:41:49+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v3.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "a7a98f40dcc382a332c3729a6d04b298ffbb8f1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/a7a98f40dcc382a332c3729a6d04b298ffbb8f1f", + "reference": "a7a98f40dcc382a332c3729a6d04b298ffbb8f1f", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2020-03-15T09:38:08+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "platform-overrides": { + "php": "5.6.0" + } +} diff --git a/config.xml b/config.xml index 60fc400..14ecf7c 100644 --- a/config.xml +++ b/config.xml @@ -1,11 +1,12 @@ - displayordercarrier - - - - - 0 - 0 + displayordercarrier + + + + + + 1 + 0 - + \ No newline at end of file diff --git a/controllers/admin/AdminDisplayOrderCarrierController.php b/controllers/admin/AdminDisplayOrderCarrierController.php index 570269b..6d06a68 100755 --- a/controllers/admin/AdminDisplayOrderCarrierController.php +++ b/controllers/admin/AdminDisplayOrderCarrierController.php @@ -1,58 +1,51 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -class AdminDisplayOrderCarrierController extends ModuleAdminController -{ - /** - * Constructor. - */ - public function __construct() - { - $this->bootstrap = true; - $this->className = 'Configuration'; - $this->table = 'configuration'; - - parent::__construct(); - - $this->fields_options = [ - 'products' => [ - 'title' => $this->l('Display Carrier on Order list'), - 'fields' => [ - DisplayOrderCarrier::CONFIGURATION_KEY_SHOW_LOGO => [ - 'title' => $this->l('Show logo instead of carrier name'), - 'validation' => 'isBool', - 'cast' => 'intval', - 'required' => false, - 'type' => 'bool' - ], - ], - 'submit' => [ - 'title' => $this->l('Save') - ], - ] - ]; - } -} + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ +class AdminDisplayOrderCarrierController extends ModuleAdminController +{ + /** + * Constructor. + */ + public function __construct() + { + $this->bootstrap = true; + $this->className = 'Configuration'; + $this->table = 'configuration'; + + parent::__construct(); + + $this->fields_options = [ + 'products' => [ + 'title' => $this->l('Display Carrier on Order list'), + 'fields' => [ + DisplayOrderCarrier::CONFIGURATION_KEY_SHOW_LOGO => [ + 'title' => $this->l('Show logo instead of carrier name'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'required' => false, + 'type' => 'bool', + ], + ], + 'submit' => [ + 'title' => $this->l('Save'), + ], + ], + ]; + } +} diff --git a/controllers/admin/index.php b/controllers/admin/index.php index 417fedb..36c7d1f 100755 --- a/controllers/admin/index.php +++ b/controllers/admin/index.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); diff --git a/controllers/index.php b/controllers/index.php index 417fedb..36c7d1f 100755 --- a/controllers/index.php +++ b/controllers/index.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); diff --git a/displayordercarrier.php b/displayordercarrier.php index aee5051..833b974 100644 --- a/displayordercarrier.php +++ b/displayordercarrier.php @@ -1,39 +1,37 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ if (!defined('_PS_VERSION_')) { exit; } +require __DIR__ . '/vendor/autoload.php'; + class DisplayOrderCarrier extends Module { /** - * @var array list of hooks used + * List of hooks used */ - public $hooks = [ - 'actionAdminControllerSetMedia', + const HOOKS = [ + 'actionOrderGridDefinitionModifier', + 'actionOrderGridDataModifier', + 'actionOrderGridQueryBuilderModifier', 'actionAdminOrdersListingFieldsModifier', 'actionAdminOrdersListingResultsModifier', ]; @@ -55,12 +53,12 @@ public function __construct() { $this->name = 'displayordercarrier'; $this->tab = 'administration'; - $this->version = '1.0.2'; + $this->version = '1.1.0'; $this->author = 'Matt75'; $this->need_instance = 0; $this->ps_versions_compliancy = [ 'min' => '1.6.1.0', - 'max' => '1.7.7.0', // Because orders list should be migrate on 1.7.7 + 'max' => _PS_VERSION_, ]; parent::__construct(); @@ -77,7 +75,7 @@ public function __construct() public function install() { return parent::install() - && $this->registerHook($this->hooks) + && $this->registerHook(static::HOOKS) && $this->installTabs() && Configuration::updateValue(static::CONFIGURATION_KEY_SHOW_LOGO, false); } @@ -118,12 +116,18 @@ public function uninstall() && Configuration::deleteByName(static::CONFIGURATION_KEY_SHOW_LOGO); } + /** + * Uninstall Tabs + * + * @return bool + */ public function uninstallTabs() { $id_tab = (int) Tab::getIdFromClassName(static::MODULE_ADMIN_CONTROLLER); if ($id_tab) { $tab = new Tab($id_tab); + return $tab->delete(); } @@ -139,23 +143,130 @@ public function getContent() } /** - * Add CSS to fix carrier logo size in Order List page + * Hook allows to modify Order grid definition since 1.7.7.0 + * + * @param array $params + */ + public function hookActionOrderGridDefinitionModifier(array $params) + { + if (empty($params['definition'])) { + return; + } + + /** @var PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface $definition */ + $definition = $params['definition']; + + if (Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO)) { + $column = new PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ImageColumn('carrier_reference'); + $column->setName($this->l('Carrier')); + $column->setOptions([ + 'src_field' => 'carrier_logo', + 'clickable' => false, + ]); + } else { + $column = new PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn('carrier_reference'); + $column->setName($this->l('Carrier')); + $column->setOptions([ + 'field' => 'carrier_name', + ]); + } + + $definition + ->getColumns() + ->addAfter( + 'payment', + $column + ) + ; + + /** @var PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CarrierByReferenceChoiceProvider $carrierByReferenceChoiceProvider */ + $carrierByReferenceChoiceProvider = $this->get('prestashop.core.form.choice_provider.carrier_by_reference_id'); + + $definition->getFilters()->add( + (new PrestaShop\PrestaShop\Core\Grid\Filter\Filter('carrier_reference', Symfony\Component\Form\Extension\Core\Type\ChoiceType::class)) + ->setAssociatedColumn('carrier_reference') + ->setTypeOptions([ + 'required' => false, + 'choices' => $carrierByReferenceChoiceProvider->getChoices(), + 'translation_domain' => false, + ]) + ); + } + + /** + * Hook allows to modify Order grid data since 1.7.7.0 + * + * @param array $params + */ + public function hookActionOrderGridDataModifier(array $params) + { + if (empty($params['data'])) { + return; + } + + /** @var PrestaShop\PrestaShop\Core\Grid\Data\GridData $gridData */ + $gridData = $params['data']; + $modifiedRecords = $gridData->getRecords()->all(); + /** @var PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface $imageTagSourceParser */ + $imageTagSourceParser = $this->get('prestashop.core.image.parser.image_tag_source_parser'); + $carrierLogoThumbnailProvider = new \PrestaShop\Module\DisplayOrderCarrier\CarrierLogoThumbnailProvider($imageTagSourceParser); + + foreach ($modifiedRecords as $key => $data) { + if (empty($data['carrier_name'])) { + $modifiedRecords[$key]['carrier_name'] = Carrier::getCarrierNameFromShopName(); + } + $modifiedRecords[$key]['carrier_logo'] = $carrierLogoThumbnailProvider->getPath($data['id_carrier']); + } + + $params['data'] = new PrestaShop\PrestaShop\Core\Grid\Data\GridData( + new PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection($modifiedRecords), + $gridData->getRecordsTotal(), + $gridData->getQuery() + ); + } + + /** + * Hook allows to modify Order query builder and add custom sql statements since 1.7.7.0 * * @param array $params */ - public function hookActionAdminControllerSetMedia(array $params) + public function hookActionOrderGridQueryBuilderModifier(array $params) { - if ('AdminOrders' === Tools::getValue('controller') - && false === Tools::getIsset('addorder') - && false === Tools::getIsset('vieworder') - && Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO) - ) { - $this->context->controller->addCSS($this->getPathUri() . 'views/css/displayordercarrier.css', 'all'); + if (empty($params['search_query_builder']) || empty($params['search_criteria'])) { + return; + } + + /** @var Doctrine\DBAL\Query\QueryBuilder $searchQueryBuilder */ + $searchQueryBuilder = $params['search_query_builder']; + + /** @var PrestaShop\PrestaShop\Core\Search\Filters\OrderFilters $searchCriteria */ + $searchCriteria = $params['search_criteria']; + + $searchQueryBuilder->addSelect( + 'o.`id_carrier`, car.`id_reference` AS `carrier_reference`, car.`name` AS `carrier_name`' + ); + + $searchQueryBuilder->leftJoin( + 'o', + '`' . _DB_PREFIX_ . 'carrier`', + 'car', + 'car.`id_carrier` = o.`id_carrier`' + ); + + if ('carrier_reference' === $searchCriteria->getOrderBy()) { + $searchQueryBuilder->orderBy('car.`id_reference`', $searchCriteria->getOrderWay()); + } + + foreach ($searchCriteria->getFilters() as $filterName => $filterValue) { + if ('carrier_reference' === $filterName) { + $searchQueryBuilder->andWhere('car.`id_reference` = :carrier_reference'); + $searchQueryBuilder->setParameter('carrier_reference', $filterValue); + } } } /** - * Append custom fields. + * Hook allows to modify Order grid data before 1.7.7.0 * * @param array $params */ @@ -163,7 +274,7 @@ public function hookActionAdminOrdersListingFieldsModifier(array $params) { // If hook is called in AdminController::processFilter() we have to check existence if (isset($params['select'])) { - $params['select'] .= ', a.id_carrier, car.name AS carrier_name'; + $params['select'] .= ', a.id_carrier, car.id_reference AS carrier_reference, car.name AS carrier_name'; } // If hook is called in AdminController::processFilter() we have to check existence @@ -171,36 +282,76 @@ public function hookActionAdminOrdersListingFieldsModifier(array $params) $params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'carrier AS car ON (a.id_carrier = car.id_carrier)'; } + $list = []; + $carriers = Carrier::getCarriers( + (int) $this->context->employee->id_lang, + false, + false, + false, + null, + Carrier::ALL_CARRIERS + ); + + if (false === empty($carriers)) { + foreach ($carriers as $carrier) { + $list[(int) $carrier['id_reference']] = $carrier['name']; + } + } + $params['fields']['carrier_name'] = [ 'title' => $this->l('Carrier'), 'align' => 'text-center', 'class' => 'fixed-width-xs', - 'filter_key' => 'car!name', - 'order_key' => 'car!name', + 'filter_key' => 'car!id_reference', + 'order_key' => 'car!id_reference', + 'type' => 'select', + 'list' => $list, ]; if (Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO)) { - $params['fields']['carrier_name']['icon'] = true; - $params['fields']['carrier_name']['class'] .= ' column-img-carrier'; + $params['fields']['carrier_name']['callback'] = 'renderCarrierLogo'; + $params['fields']['carrier_name']['callback_object'] = $this; } } /** - * Set additional order data. + * Hook allows to modify Order grid data before 1.7.7.0 * * @param array $params */ public function hookActionAdminOrdersListingResultsModifier(array $params) { - if (Configuration::get(static::CONFIGURATION_KEY_SHOW_LOGO)) { - foreach ($params['list'] as $key => $fields) { - if (isset($fields['id_carrier'], $fields['carrier_name'])) { - $params['list'][$key]['carrier_name'] = [ - 'src' => '../s/' . (int) $fields['id_carrier'] . '.jpg', - 'alt' => Tools::safeOutput($fields['carrier_name']), - ]; - } + foreach ($params['list'] as $key => $fields) { + if (empty($fields['carrier_name'])) { + $params['list'][$key]['carrier_name'] = Carrier::getCarrierNameFromShopName(); } } } + + /** + * Callback function used by legacy HelperList to retrieve Carrier logo before 1.7.7.0 + * + * @param string $echo Carrier name + * @param array $tr Data + * + * @return string + */ + public function renderCarrierLogo($echo, $tr) + { + $logoPath = _PS_SHIP_IMG_DIR_ . (int) $tr['id_carrier'] . '.jpg'; + + if (false === Tools::file_exists_cache($logoPath)) { + $logoPath = _PS_IMG_DIR_ . '404.gif'; + } + + return str_replace( + 'alt=""', + 'alt="' . $echo . '" title="' . $echo . '"', + ImageManager::thumbnail( + $logoPath, + 'carrier_mini_' . (int) $tr['id_carrier'] . '.jpg', + 34 + ) + ); + } } diff --git a/index.php b/index.php index 417fedb..36c7d1f 100644 --- a/index.php +++ b/index.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); diff --git a/src/CarrierLogoThumbnailProvider.php b/src/CarrierLogoThumbnailProvider.php new file mode 100644 index 0000000..26b13c7 --- /dev/null +++ b/src/CarrierLogoThumbnailProvider.php @@ -0,0 +1,66 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ + +namespace PrestaShop\Module\DisplayOrderCarrier; + +use HelperList; +use ImageManager; +use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; +use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; +use Tools; + +/** + * Provides path for carrier logo thumbnail + */ +final class CarrierLogoThumbnailProvider implements ImageProviderInterface +{ + /** + * @var ImageTagSourceParserInterface + */ + private $imageTagSourceParser; + + /** + * @param ImageTagSourceParserInterface $imageTagSourceParser + */ + public function __construct(ImageTagSourceParserInterface $imageTagSourceParser) + { + $this->imageTagSourceParser = $imageTagSourceParser; + } + + /** + * {@inheritdoc} + */ + public function getPath($imageId) + { + $pathToImage = _PS_SHIP_IMG_DIR_ . $imageId . '.jpg'; + + if (false === Tools::file_exists_cache($pathToImage)) { + $pathToImage = _PS_IMG_DIR_ . '404.gif'; + } + + $imageTag = ImageManager::thumbnail( + $pathToImage, + 'carrier_mini_' . $imageId . '.jpg', + HelperList::LIST_THUMBNAIL_SIZE + ); + + return $this->imageTagSourceParser->parse($imageTag); + } +} diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..36c7d1f --- /dev/null +++ b/src/index.php @@ -0,0 +1,28 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon new file mode 100644 index 0000000..0f09fa9 --- /dev/null +++ b/tests/phpstan/phpstan.neon @@ -0,0 +1,34 @@ +includes: + - %currentWorkingDirectory%/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon + +parameters: + paths: + # From PHPStan 0.12, paths to check are relative to the neon file + - ../../controllers + - ../../displayordercarrier.php + reportUnmatchedIgnoredErrors: false + ignoreErrors: + - '#Property ModuleCore::\$version \(float\) does not accept string.#' + - '#Parameter \#7 \$currency_special of method PaymentModuleCore::validateOrder\(\) expects null, int given.#' + - '#Parameter \#9 \$secure_key of method PaymentModuleCore::validateOrder\(\) expects bool, string given.#' + - '#Strict comparison using === between false and string will always evaluate to false.#' + - '#Strict comparison using === between false and true will always evaluate to false.#' + - '#Parameter \#1 \$id of class Customer constructor expects null, int given.#' + - '#Parameter \#1 \$hook_name of method ModuleCore::registerHook\(\) expects string, array given.#' + - '#Parameter \#6 \$idShop of method LinkCore::getModuleLink\(\) expects null, int given.#' + - '#Parameter \#1 \$id_hook of method ModuleCore::updatePosition\(\) expects bool, int given.#' + - '#Property TabCore::\$name \(string\) does not accept array.#' + - '#Access to an undefined property PaymentModule::\$currentOrderReference.#' + - '#Property CustomerCore::\$passwd \(int\) does not accept bool\|string.#' + - '#Parameter \#4 \$ssl of method LinkCore::getModuleLink\(\) expects null, true given.#' + - '#Parameter \#1 \$id of class Currency constructor expects null, int given.#' + - '#Property OrderStateCore::\$name \(string\) does not accept array.#' + - '#Access to an undefined property object::\$status.#' + - '#Access to an undefined property object::\$id.#' + - '#Class PrestaShop\\PrestaShop\\Core\\Image\\ImageProviderInterface not found.#' + - '#PHPDoc tag \@var for variable \$searchCriteria contains unknown class PrestaShop\\PrestaShop\\Core\\Search\\Filters\\OrderFilters.#' + - '#Call to method getOrderBy\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Search\\Filters\\OrderFilters.#' + - '#Call to method getOrderWay\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Search\\Filters\\OrderFilters.#' + - '#Call to method getFilters\(\) on an unknown class PrestaShop\\PrestaShop\\Core\\Search\\Filters\\OrderFilters.#' + + level: 5 diff --git a/translations/fr.php b/translations/fr.php index a84e7e6..922424b 100644 --- a/translations/fr.php +++ b/translations/fr.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - global $_MODULE; -$_MODULE = array(); +$_MODULE = []; $_MODULE['<{displayordercarrier}prestashop>displayordercarrier_0c6b21631c4abcee17e4f05445ffa029'] = 'Colonne transporteur sur la liste des commandes'; $_MODULE['<{displayordercarrier}prestashop>displayordercarrier_610d2185e454143c833b2ab478e3843f'] = 'Ajoute une colonne transporteur sur la liste des commandes'; $_MODULE['<{displayordercarrier}prestashop>displayordercarrier_914419aa32f04011357d3b604a86d7eb'] = 'Transporteur'; diff --git a/translations/index.php b/translations/index.php index 417fedb..36c7d1f 100644 --- a/translations/index.php +++ b/translations/index.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); diff --git a/upgrade/index.php b/upgrade/index.php index 417fedb..36c7d1f 100644 --- a/upgrade/index.php +++ b/upgrade/index.php @@ -1,31 +1,24 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); diff --git a/upgrade/upgrade-1.0.1.php b/upgrade/upgrade-1.0.1.php deleted file mode 100644 index 3a511dc..0000000 --- a/upgrade/upgrade-1.0.1.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ -if (!defined('_PS_VERSION_')) { - exit; -} - -/** - * @param DisplayOrderCarrier $module - * - * @return bool - */ -function upgrade_module_1_0_1($module) -{ - return $module->registerHook('actionAdminControllerSetMedia'); -} diff --git a/upgrade/upgrade-1.0.2.php b/upgrade/upgrade-1.0.2.php index 4e272c1..9a738d0 100644 --- a/upgrade/upgrade-1.0.2.php +++ b/upgrade/upgrade-1.0.2.php @@ -1,27 +1,21 @@ - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ if (!defined('_PS_VERSION_')) { exit; diff --git a/upgrade/upgrade-1.1.0.php b/upgrade/upgrade-1.1.0.php new file mode 100644 index 0000000..a4befef --- /dev/null +++ b/upgrade/upgrade-1.1.0.php @@ -0,0 +1,32 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * @param DisplayOrderCarrier $module + * + * @return bool + */ +function upgrade_module_1_1_0($module) +{ + return $module->registerHook(DisplayOrderCarrier::HOOKS); +} diff --git a/views/css/displayordercarrier.css b/views/css/displayordercarrier.css deleted file mode 100644 index afa6663..0000000 --- a/views/css/displayordercarrier.css +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 2007-2019 PrestaShop SA and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -.column-img-carrier img { - max-height: 30px; - max-width: 30px; -} diff --git a/views/css/index.php b/views/css/index.php deleted file mode 100644 index 417fedb..0000000 --- a/views/css/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/views/index.php b/views/index.php deleted file mode 100644 index 417fedb..0000000 --- a/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit;