Merge pull request #340 from acelaya/bugfix/preview-error

Bugfix/preview error
This commit is contained in:
Alejandro Celaya 2019-01-28 11:00:23 +01:00 committed by GitHub
commit 967f1657d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 14 deletions

View file

@ -2,7 +2,7 @@
namespace PHPSTORM_META;
use Psr\Container\ContainerInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* PhpStorm Container Interop code completion
@ -17,7 +17,7 @@ $STATIC_METHOD_TYPES = [
ContainerInterface::get('') => [
'' == '@',
],
ServiceManager::build('') => [
ServiceLocatorInterface::build('') => [
'' == '@',
],
];

View file

@ -47,7 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
#### Fixed
* *Nothing*
* [#317](https://github.com/shlinkio/shlink/issues/317) Fixed error while trying to generate previews because of global config file being deleted by mistake by build script.
## 1.15.1 - 2018-12-16

View file

@ -105,7 +105,8 @@
"test": [
"@test:unit",
"@test:db"
"@test:db",
"@test:api"
],
"test:ci": [
"@test:unit:ci",

View file

@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Core\Service\UrlShortener;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use function Shlinkio\Shlink\Common\env;
return [
@ -11,7 +11,7 @@ return [
'schema' => env('SHORTENED_URL_SCHEMA', 'http'),
'hostname' => env('SHORTENED_URL_HOSTNAME'),
],
'shortcode_chars' => env('SHORTCODE_CHARS', UrlShortener::DEFAULT_CHARS),
'shortcode_chars' => env('SHORTCODE_CHARS', UrlShortenerOptions::DEFAULT_CHARS),
'validate_url' => true,
'not_found_short_url' => [
'enable_redirection' => false,

View file

@ -3,9 +3,9 @@ declare(strict_types=1);
return [
'phpwkhtmltopdf' => [
'wkhtmltopdf' => [
'images' => [
'binary' => 'bin/wkhtmltoimage',
'binary' => __DIR__ . '/../../bin/wkhtmltoimage',
'type' => 'jpg',
],
],

View file

@ -7,7 +7,7 @@ use function sprintf;
class PreviewGenerationException extends RuntimeException
{
public static function fromImageError($error)
public static function fromImageError(string $error): self
{
return new self(sprintf('Error generating a preview image with error: %s', $error));
}

View file

@ -26,7 +26,7 @@ class ImageFactory implements FactoryInterface
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$config = $container->get('config')['phpwkhtmltopdf'];
$config = $container->get('config')['wkhtmltopdf'];
$image = new Image($config['images'] ?? null);
if ($options['url'] ?? null) {

View file

@ -19,7 +19,7 @@ class PreviewGenerator implements PreviewGeneratorInterface
/** @var Filesystem */
private $filesystem;
public function __construct(ImageBuilderInterface $imageBuilder, Filesystem $filesystem, $location)
public function __construct(ImageBuilderInterface $imageBuilder, Filesystem $filesystem, string $location)
{
$this->location = $location;
$this->imageBuilder = $imageBuilder;
@ -33,7 +33,6 @@ class PreviewGenerator implements PreviewGeneratorInterface
*/
public function generatePreview(string $url): string
{
/** @var Image $image */
$image = $this->imageBuilder->build(Image::class, ['url' => $url]);
// If the file already exists, return its path

View file

@ -26,7 +26,7 @@ class ImageFactoryTest extends TestCase
{
/** @var Image $image */
$image = $this->factory->__invoke(new ServiceManager(['services' => [
'config' => ['phpwkhtmltopdf' => []],
'config' => ['wkhtmltopdf' => []],
]]), '');
$this->assertInstanceOf(Image::class, $image);
@ -45,7 +45,7 @@ class ImageFactoryTest extends TestCase
/** @var Image $image */
$image = $this->factory->__invoke(new ServiceManager(['services' => [
'config' => ['phpwkhtmltopdf' => []],
'config' => ['wkhtmltopdf' => []],
]]), '', ['url' => $expectedPage]);
$this->assertInstanceOf(Image::class, $image);