From 568367b59e86d29ea5fadf433bcaae00b6be6bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Tue, 13 Aug 2019 13:04:31 +0200 Subject: [PATCH] Added an console command for updating currency exchange rates. --- .env | 2 +- composer.json | 5 + composer.lock | 1258 ++++++++++++++++-- config/packages/nyholm_psr7.yaml | 21 + config/services.yaml | 5 + src/Command/UpdateExchangeRatesCommand.php | 102 ++ src/Form/AdminPages/CurrencyAdminForm.php | 1 + symfony.lock | 66 + templates/AdminPages/CurrencyAdmin.html.twig | 2 +- 9 files changed, 1371 insertions(+), 91 deletions(-) create mode 100644 config/packages/nyholm_psr7.yaml create mode 100644 src/Command/UpdateExchangeRatesCommand.php diff --git a/.env b/.env index 2537e866..6ad69ce3 100644 --- a/.env +++ b/.env @@ -37,6 +37,6 @@ MAILER_URL=null://localhost ### Custom vars - +FIXER_API_KEY=CHANGEME ### End custom vars \ No newline at end of file diff --git a/composer.json b/composer.json index 7faac738..c255ddb1 100644 --- a/composer.json +++ b/composer.json @@ -8,10 +8,15 @@ "ext-intl": "*", "ext-mbstring": "*", "doctrine/annotations": "^1.6", + "florianv/swap": "^4.0", "friendsofsymfony/ckeditor-bundle": "^2.0", "gerardojbaez/money": "^0.3.1", + "nyholm/psr7": "^1.1", "ocramius/proxy-manager": "2.1.*", "omines/datatables-bundle": "^0.2.2", + "php-http/curl-client": "^2.0", + "php-http/guzzle6-adapter": "^2.0", + "php-http/message": "^1.8", "php-translation/symfony-bundle": "^0.8.1", "s9e/text-formatter": "^2.0", "sensio/framework-extra-bundle": "^5.1", diff --git a/composer.lock b/composer.lock index bf944ff3..2e38819d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,72 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4efee728068f5b14ad389d7a4a75131b", + "content-hash": "a10f4a3cafdc520a3c6286e2e6c3b84a", "packages": [ { - "name": "doctrine/annotations", - "version": "v1.6.1", + "name": "clue/stream-filter", + "version": "v1.4.1", "source": { "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24" + "url": "https://github.com/clue/php-stream-filter.git", + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/53120e0eb10355388d6ccbe462f1fea34ddadb24", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "time": "2019-04-09T12:31:48+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "fa4c4e861e809d6a1103bd620cce63ed91aedfeb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/fa4c4e861e809d6a1103bd620cce63ed91aedfeb", + "reference": "fa4c4e861e809d6a1103bd620cce63ed91aedfeb", "shasum": "" }, "require": { @@ -26,12 +78,12 @@ }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^7.5@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -44,6 +96,10 @@ "MIT" ], "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -52,10 +108,6 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" @@ -72,7 +124,7 @@ "docblock", "parser" ], - "time": "2019-03-25T19:12:02+00:00" + "time": "2019-08-08T18:11:40+00:00" }, { "name": "doctrine/cache", @@ -1319,6 +1371,127 @@ ], "time": "2016-10-17T18:31:11+00:00" }, + { + "name": "florianv/exchanger", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/florianv/exchanger.git", + "reference": "602723c0dac212225c01f914545de316b4373c67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/florianv/exchanger/zipball/602723c0dac212225c01f914545de316b4373c67", + "reference": "602723c0dac212225c01f914545de316b4373c67", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "php-http/client-implementation": "^1.0", + "php-http/discovery": "^1.6", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0.2", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "php-http/message": "^1.7", + "php-http/mock-client": "^1.0", + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "php-http/guzzle6-adapter": "Required to use Guzzle for sending HTTP requests", + "php-http/message": "Required to use Guzzle for sending HTTP requests" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Exchanger\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Florian Voutzinos", + "email": "florian@voutzinos.com", + "homepage": "https://voutzinos.com" + } + ], + "description": "Currency exchange rates framework for PHP", + "homepage": "https://github.com/florianv/exchanger", + "keywords": [ + "Rate", + "conversion", + "currency", + "exchange rates", + "money" + ], + "time": "2019-05-22T14:33:08+00:00" + }, + { + "name": "florianv/swap", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/florianv/swap.git", + "reference": "89128edec43cec06b65f0d90141512e91e5e14bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/florianv/swap/zipball/89128edec43cec06b65f0d90141512e91e5e14bf", + "reference": "89128edec43cec06b65f0d90141512e91e5e14bf", + "shasum": "" + }, + "require": { + "florianv/exchanger": "^2.0", + "php": "^7.1.3" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "php-http/message": "^1.7", + "php-http/mock-client": "^1.0", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Swap\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Florian Voutzinos", + "email": "florian@voutzinos.com", + "homepage": "https://voutzinos.com" + } + ], + "description": "Exchange rates library for PHP", + "keywords": [ + "Rate", + "conversion", + "currency", + "exchange rates", + "money" + ], + "time": "2019-05-30T10:44:39+00:00" + }, { "name": "friendsofsymfony/ckeditor-bundle", "version": "2.1.0", @@ -1445,6 +1618,193 @@ ], "time": "2018-02-24T18:59:00+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-04-22T15:46:56+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, { "name": "jdorn/sql-formatter", "version": "v1.2.17", @@ -1575,16 +1935,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.2.2", + "version": "v4.2.3", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" + "reference": "e612609022e935f3d0337c1295176505b41188c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/e612609022e935f3d0337c1295176505b41188c8", + "reference": "e612609022e935f3d0337c1295176505b41188c8", "shasum": "" }, "require": { @@ -1592,7 +1952,7 @@ "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^6.5 || ^7.0" + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0" }, "bin": [ "bin/php-parse" @@ -1622,42 +1982,39 @@ "parser", "php" ], - "time": "2019-05-25T20:07:01+00:00" + "time": "2019-08-12T20:17:41+00:00" }, { "name": "nikolaposa/version", - "version": "2.2.2", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/nikolaposa/version.git", - "reference": "9fd723babf6fccc9ee221e3b987348af0b00a8c7" + "reference": "7ff2bbf2fe6a47efe47832d6198924e99b4a4f5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikolaposa/version/zipball/9fd723babf6fccc9ee221e3b987348af0b00a8c7", - "reference": "9fd723babf6fccc9ee221e3b987348af0b00a8c7", + "url": "https://api.github.com/repos/nikolaposa/version/zipball/7ff2bbf2fe6a47efe47832d6198924e99b4a4f5a", + "reference": "7ff2bbf2fe6a47efe47832d6198924e99b4a4f5a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^1.11", - "phpunit/phpunit": "^4.7" + "friendsofphp/php-cs-fixer": "^2.0", + "phpunit/phpunit": "^6.0 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "3.2.x-dev" } }, "autoload": { "psr-4": { "Version\\": "src/" - }, - "classmap": [ - "src/" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1667,7 +2024,7 @@ { "name": "Nikola Poša", "email": "posa.nikola@gmail.com", - "homepage": "http://www.nikolaposa.in.rs" + "homepage": "https://www.nikolaposa.in.rs" } ], "description": "Value Object that represents a SemVer-compliant version number.", @@ -1678,7 +2035,7 @@ "version", "versioning" ], - "time": "2018-04-22T08:54:55+00:00" + "time": "2019-08-11T08:31:54+00:00" }, { "name": "nyholm/nsa", @@ -1727,6 +2084,68 @@ ], "time": "2017-04-13T17:21:01+00:00" }, + { + "name": "nyholm/psr7", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7.git", + "reference": "701fe7ea8c12c07b985b156d589134d328160cf7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/701fe7ea8c12c07b985b156d589134d328160cf7", + "reference": "701fe7ea8c12c07b985b156d589134d328160cf7", + "shasum": "" + }, + "require": { + "php": "^7.1", + "php-http/message-factory": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "dev-master", + "php-http/psr7-integration-tests": "dev-master", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Nyholm\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "A fast PHP7 implementation of PSR-7", + "homepage": "http://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "time": "2019-02-16T17:20:43+00:00" + }, { "name": "ocramius/package-versions", "version": "1.5.1", @@ -1933,6 +2352,427 @@ ], "time": "2019-02-25T09:17:27+00:00" }, + { + "name": "php-http/curl-client", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/curl-client.git", + "reference": "e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da", + "reference": "e7a2a5ebcce1ff7d75eaf02b7c85634a6fac00da", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^7.1", + "php-http/discovery": "^1.6", + "php-http/httplug": "^2.0", + "php-http/message": "^1.2", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "symfony/options-resolver": "^3.4 || ^4.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "php-http/client-integration-tests": "^2.0", + "phpunit/phpunit": "^7.5", + "zendframework/zend-diactoros": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "description": "PSR-18 and HTTPlug Async client with cURL", + "homepage": "http://php-http.org", + "keywords": [ + "curl", + "http", + "psr-18" + ], + "time": "2019-03-05T19:59:23+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "e822f86a6983790aa17ab13aa7e69631e86806b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/e822f86a6983790aa17ab13aa7e69631e86806b6", + "reference": "e822f86a6983790aa17ab13aa7e69631e86806b6", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^4.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "time": "2019-06-30T09:04:27+00:00" + }, + { + "name": "php-http/guzzle6-adapter", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/guzzle6-adapter.git", + "reference": "6074a4b1f4d5c21061b70bab3b8ad484282fe31f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/6074a4b1f4d5c21061b70bab3b8ad484282fe31f", + "reference": "6074a4b1f4d5c21061b70bab3b8ad484282fe31f", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "php": "^7.1", + "php-http/httplug": "^2.0", + "psr/http-client": "^1.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "ext-curl": "*", + "php-http/client-integration-tests": "^2.0", + "phpunit/phpunit": "^7.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Adapter\\Guzzle6\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "David de Boer", + "email": "david@ddeboer.nl" + } + ], + "description": "Guzzle 6 HTTP Adapter", + "homepage": "http://httplug.io", + "keywords": [ + "Guzzle", + "http" + ], + "time": "2018-12-16T14:44:03+00:00" + }, + { + "name": "php-http/httplug", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "b3842537338c949f2469557ef4ad4bdc47b58603" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/b3842537338c949f2469557ef4ad4bdc47b58603", + "reference": "b3842537338c949f2469557ef4ad4bdc47b58603", + "shasum": "" + }, + "require": { + "php": "^7.0", + "php-http/promise": "^1.0", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "time": "2018-10-31T09:14:44+00:00" + }, + { + "name": "php-http/message", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/ce8f43ac1e294b54aabf5808515c3554a19c1e1c", + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.4", + "php": "^7.1", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "slim/slim": "^3.0", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "zendframework/zend-diactoros": "Used with Diactoros Factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "time": "2019-08-05T06:55:08+00:00" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/promise", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "shasum": "" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "time": "2016-01-26T13:27:02+00:00" + }, { "name": "php-translation/common", "version": "1.0.0", @@ -2388,6 +3228,157 @@ ], "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e", + "reference": "496a823ef742b632934724bf769560c2a5c7c44e", + "shasum": "" + }, + "require": { + "php": "^7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "time": "2018-10-30T23:29:13+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/link", "version": "1.0.0", @@ -2484,6 +3475,94 @@ ], "time": "2018-11-20T15:27:04+00:00" }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "s9e/regexp-builder", "version": "1.4.3", @@ -2524,16 +3603,16 @@ }, { "name": "s9e/text-formatter", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/s9e/TextFormatter.git", - "reference": "6902c1dc06fccea08565b8966c5a2cf01e3bc85f" + "reference": "0c6ba01d3a30ee01c3ac7dd66a87712023a88962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/6902c1dc06fccea08565b8966c5a2cf01e3bc85f", - "reference": "6902c1dc06fccea08565b8966c5a2cf01e3bc85f", + "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/0c6ba01d3a30ee01c3ac7dd66a87712023a88962", + "reference": "0c6ba01d3a30ee01c3ac7dd66a87712023a88962", "shasum": "" }, "require": { @@ -2545,7 +3624,7 @@ }, "require-dev": { "matthiasmullie/minify": "*", - "phpunit/phpunit": "^7 || ^8.2" + "phpunit/phpunit": "^7 || 8.2.*" }, "suggest": { "ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers", @@ -2558,7 +3637,7 @@ }, "type": "library", "extra": { - "version": "2.1.0" + "version": "2.1.1" }, "autoload": { "psr-4": { @@ -2588,7 +3667,7 @@ "parser", "shortcodes" ], - "time": "2019-07-24T10:59:43+00:00" + "time": "2019-08-05T06:08:54+00:00" }, { "name": "sensio/framework-extra-bundle", @@ -2665,28 +3744,29 @@ }, { "name": "shivas/versioning-bundle", - "version": "3.1.3", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/shivas/versioning-bundle.git", - "reference": "ff92fb096646a1330f1e72cdd8ed83a581079450" + "reference": "757022a2adf5798af13dcc945394ad2400a20ca9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shivas/versioning-bundle/zipball/ff92fb096646a1330f1e72cdd8ed83a581079450", - "reference": "ff92fb096646a1330f1e72cdd8ed83a581079450", + "url": "https://api.github.com/repos/shivas/versioning-bundle/zipball/757022a2adf5798af13dcc945394ad2400a20ca9", + "reference": "757022a2adf5798af13dcc945394ad2400a20ca9", "shasum": "" }, "require": { - "nikolaposa/version": "^2.2", + "nikolaposa/version": "^2.2 || ^3.0", "php": "^7.0", - "symfony/console": "^3.4|^4.0", - "symfony/framework-bundle": "^3.4|^4.0", - "symfony/process": "^3.4|^4.0" + "symfony/console": "^3.4 || ^4.0", + "symfony/framework-bundle": "^3.4 || ^4.0", + "symfony/process": "^3.4 || ^4.0" }, "require-dev": { - "composer/composer": "^1.0", - "phpunit/phpunit": "^5.5" + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^6.5 || ^7", + "symfony/phpunit-bridge": "^4.3" }, "type": "symfony-bundle", "autoload": { @@ -2701,8 +3781,8 @@ "authors": [ { "name": "Audrius Karabanovas", - "email": "audrius@karabanovas.net", - "role": "Developer" + "role": "Developer", + "email": "audrius@karabanovas.net" } ], "description": "Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations", @@ -2713,7 +3793,7 @@ "version", "versioning" ], - "time": "2018-04-30T06:42:35+00:00" + "time": "2019-08-09T17:22:14+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -4492,21 +5572,21 @@ }, { "name": "symfony/polyfill-intl-icu", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-icu.git", - "reference": "999878a3a09d73cae157b0cf89bb6fb2cc073057" + "reference": "66810b9d6eb4af54d543867909d65ab9af654d7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/999878a3a09d73cae157b0cf89bb6fb2cc073057", - "reference": "999878a3a09d73cae157b0cf89bb6fb2cc073057", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/66810b9d6eb4af54d543867909d65ab9af654d7e", + "reference": "66810b9d6eb4af54d543867909d65ab9af654d7e", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/intl": "~2.3|~3.0|~4.0" + "symfony/intl": "~2.3|~3.0|~4.0|~5.0" }, "suggest": { "ext-intl": "For best performance" @@ -4514,7 +5594,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -4546,20 +5626,20 @@ "portable", "shim" ], - "time": "2019-01-07T19:39:47+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af" + "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c766e95bec706cdd89903b1eda8afab7d7a6b7af", - "reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", + "reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2", "shasum": "" }, "require": { @@ -4573,7 +5653,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -4589,13 +5669,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Laurent Bassin", "email": "laurent@bassin.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", @@ -4608,20 +5688,20 @@ "portable", "shim" ], - "time": "2019-03-04T13:44:35+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", "shasum": "" }, "require": { @@ -4633,7 +5713,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -4667,20 +5747,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c" + "reference": "04ce3335667451138df4307d6a9b61565560199e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/ab50dcf166d5f577978419edd37aa2bb8eabce0c", - "reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", + "reference": "04ce3335667451138df4307d6a9b61565560199e", "shasum": "" }, "require": { @@ -4689,7 +5769,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -4722,20 +5802,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", "shasum": "" }, "require": { @@ -4744,7 +5824,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -4780,7 +5860,7 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/process", diff --git a/config/packages/nyholm_psr7.yaml b/config/packages/nyholm_psr7.yaml new file mode 100644 index 00000000..f1357233 --- /dev/null +++ b/config/packages/nyholm_psr7.yaml @@ -0,0 +1,21 @@ +services: + # Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories) + Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory' + + # Register nyholm/psr7 services for autowiring with HTTPlug factories + Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory' + Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory' + Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory' + Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory' + Http\Message\UriFactory: '@nyholm.psr7.httplug_factory' + + nyholm.psr7.psr17_factory: + class: Nyholm\Psr7\Factory\Psr17Factory + + nyholm.psr7.httplug_factory: + class: Nyholm\Psr7\Factory\HttplugFactory diff --git a/config/services.yaml b/config/services.yaml index c5542897..47890851 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -37,5 +37,10 @@ services: tags: - { name: "doctrine.orm.entity_listener" } + App\Command\UpdateExchangeRatesCommand: + arguments: + $base_current: '%default_currency%' + + # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones diff --git a/src/Command/UpdateExchangeRatesCommand.php b/src/Command/UpdateExchangeRatesCommand.php new file mode 100644 index 00000000..ce086df0 --- /dev/null +++ b/src/Command/UpdateExchangeRatesCommand.php @@ -0,0 +1,102 @@ +swap = $swap; + $this->base_current = $base_current; + + $this->em = $entityManager; + + parent::__construct(); + } + + protected function configure() + { + $this + ->setDescription('Updates the currency exchange rates.') + ->addArgument('iso_code', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The ISO Codes of the currencies that should be updated.') + ->addOption('service', null, InputOption::VALUE_REQUIRED, + 'Which service should be used for requesting the exchange rates (e.g. fixer). See florianv/swap for full list.', + 'exchange_rates_api') + ->addOption('api_key', null, InputOption::VALUE_REQUIRED, + 'The API key to use for the service.', + null); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + + //Check for valid base current + if (strlen($this->base_current) !== 3) { + $io->error("Choosen Base current is not valid. Check your settings!"); + return; + } + + $io->note('Update currency exchange rates with base currency: ' . $this->base_current); + + $service = $input->getOption('service'); + $api_key = $input->getOption('api_key'); + + //Construct Swap with the given options + $swap = (new Builder()) + ->add($service, ['access_key' => $api_key]) + ->build(); + + //Check what currencies we need to update: + $iso_code = $input->getArgument('iso_code'); + $repo = $this->em->getRepository(Currency::class); + $candidates = array(); + + if (!empty($iso_code)) { + $candidates = $repo->findBy(['iso_code' => $iso_code]); + } else { + $candidates = $repo->findAll(); + } + + $success_counter = 0; + + //Iterate over each candidate and update exchange rate + foreach ($candidates as $currency) { + try { + $rate = $swap->latest($currency->getIsoCode() . '/' . $this->base_current); + $currency->setExchangeRate($rate->getValue()); + $io->note(sprintf('Set exchange rate of %s to %f', $currency->getIsoCode(), $currency->getExchangeRate())); + $this->em->persist($currency); + + $success_counter++; + } catch (\Exchanger\Exception\Exception $ex) { + $io->warning(sprintf('Error updating %s:', $currency->getIsoCode())); + $io->warning($ex->getMessage()); + } + + } + + //Save to database + $this->em->flush(); + + $io->success(sprintf('%d (of %d) currency exchange rates were updated.', $success_counter, count($candidates))); + } +} diff --git a/src/Form/AdminPages/CurrencyAdminForm.php b/src/Form/AdminPages/CurrencyAdminForm.php index 75323b2f..56478c11 100644 --- a/src/Form/AdminPages/CurrencyAdminForm.php +++ b/src/Form/AdminPages/CurrencyAdminForm.php @@ -52,6 +52,7 @@ class CurrencyAdminForm extends BaseEntityAdminForm $builder->add('exchange_rate', MoneyType::class, ['required' => false, 'label' => 'currency.exchange_rate.label', 'currency' => $this->params->get('default_currency'), + 'scale' => 6, 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]); } } \ No newline at end of file diff --git a/symfony.lock b/symfony.lock index e1b7ca09..fa1c9d2b 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,4 +1,7 @@ { + "clue/stream-filter": { + "version": "v1.4.1" + }, "doctrine/annotations": { "version": "1.0", "recipe": { @@ -96,6 +99,12 @@ "fig/link-util": { "version": "1.0.0" }, + "florianv/exchanger": { + "version": "1.4.1" + }, + "florianv/swap": { + "version": "3.5.0" + }, "friendsofsymfony/ckeditor-bundle": { "version": "2.0", "recipe": { @@ -111,6 +120,15 @@ "gerardojbaez/money": { "version": "v0.3.1" }, + "guzzlehttp/guzzle": { + "version": "6.3.3" + }, + "guzzlehttp/promises": { + "version": "v1.3.1" + }, + "guzzlehttp/psr7": { + "version": "1.6.1" + }, "jdorn/sql-formatter": { "version": "v1.2.17" }, @@ -126,6 +144,18 @@ "nyholm/nsa": { "version": "1.1.0" }, + "nyholm/psr7": { + "version": "1.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "1.0", + "ref": "0cd4d2d0e7f646fda75f9944f747a56e6ed13d4c" + }, + "files": [ + "./config/packages/nyholm_psr7.yaml" + ] + }, "ocramius/proxy-manager": { "version": "2.1.1" }, @@ -141,6 +171,27 @@ "./config/packages/datatables.yaml" ] }, + "php-http/curl-client": { + "version": "2.0.0" + }, + "php-http/discovery": { + "version": "1.7.0" + }, + "php-http/guzzle6-adapter": { + "version": "v2.0.1" + }, + "php-http/httplug": { + "version": "v2.0.0" + }, + "php-http/message": { + "version": "1.8.0" + }, + "php-http/message-factory": { + "version": "v1.0.2" + }, + "php-http/promise": { + "version": "v1.0.0" + }, "php-translation/common": { "version": "1.0.0" }, @@ -180,12 +231,27 @@ "psr/container": { "version": "1.0.0" }, + "psr/http-client": { + "version": "1.0.0" + }, + "psr/http-factory": { + "version": "1.0.1" + }, + "psr/http-message": { + "version": "1.0.1" + }, "psr/link": { "version": "1.0.0" }, "psr/log": { "version": "1.1.0" }, + "psr/simple-cache": { + "version": "1.0.1" + }, + "ralouphie/getallheaders": { + "version": "3.0.3" + }, "roave/security-advisories": { "version": "dev-master" }, diff --git a/templates/AdminPages/CurrencyAdmin.html.twig b/templates/AdminPages/CurrencyAdmin.html.twig index 283e7ec9..5bc6fd59 100644 --- a/templates/AdminPages/CurrencyAdmin.html.twig +++ b/templates/AdminPages/CurrencyAdmin.html.twig @@ -20,7 +20,7 @@ {{ form_row(form.exchange_rate) }} {% if entity.inverseExchangeRate %} - {{ '1'|format_currency(default_currency) }} = {{ entity.inverseExchangeRate | format_currency(entity.isoCode) }} + {{ '1'|format_currency(default_currency) }} = {{ entity.inverseExchangeRate | format_currency(entity.isoCode, {fraction_digit: 5}) }} {% endif %} {% endblock %} \ No newline at end of file