Merge pull request #1040 from acelaya-forks/feature/endroid-4.0

Feature/endroid 4.0
This commit is contained in:
Alejandro Celaya 2021-02-28 16:56:11 +01:00 committed by GitHub
commit 3d99819be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
### Changed
* [#1036](https://github.com/shlinkio/shlink/issues/1036) Updated to `happyr/doctrine-specification` 2.0.
* [#1039](https://github.com/shlinkio/shlink/issues/1039) Updated to `endroid/qr-code` 4.0.
### Deprecated
* *Nothing*

View File

@ -21,7 +21,7 @@
"doctrine/cache": "^1.9",
"doctrine/migrations": "^3.0.2",
"doctrine/orm": "2.8.1 || ^2.8.3",
"endroid/qr-code": "dev-master#0f1613a as 3.10",
"endroid/qr-code": "^4.0",
"geoip2/geoip2": "^2.9",
"guzzlehttp/guzzle": "^7.0",
"happyr/doctrine-specification": "^2.0",
@ -46,7 +46,7 @@
"predis/predis": "^1.1",
"pugx/shortid-php": "^0.7",
"ramsey/uuid": "^3.9",
"shlinkio/shlink-common": "^3.5",
"shlinkio/shlink-common": "^3.6",
"shlinkio/shlink-config": "^1.0",
"shlinkio/shlink-event-dispatcher": "^2.1",
"shlinkio/shlink-importer": "^2.2",

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Action;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Writer\SvgWriter;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
@ -50,16 +50,17 @@ class QrCodeAction implements MiddlewareInterface
}
$query = $request->getQueryParams();
$qrCode = new QrCode($this->stringifier->stringify($shortUrl));
$qrCode->setSize($this->resolveSize($request, $query));
$qrCode->setMargin($this->resolveMargin($query));
$qrCode = Builder::create()
->data($this->stringifier->stringify($shortUrl))
->size($this->resolveSize($request, $query))
->margin($this->resolveMargin($query));
$format = $query['format'] ?? 'png';
if ($format === 'svg') {
$qrCode->setWriter(new SvgWriter());
$qrCode->writer(new SvgWriter());
}
return new QrCodeResponse($qrCode);
return new QrCodeResponse($qrCode->build());
}
private function resolveSize(Request $request, array $query): int