Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade 2.0 from 1.0 #1199

Merged
merged 67 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
46c7db1
change symfony kernel version comparison mechanism
robfrawley May 20, 2017
6cef67f
code style fixes
robfrawley May 20, 2017
4c313a2
remove symfony 3.3 from allowed failures
robfrawley May 21, 2017
251006a
[enqueue] Improve doc.
makasim May 25, 2017
73c780c
Merge pull request #942 from formapro-forks/enqueue-doc
makasim Jun 2, 2017
6857ef5
move to trusty for travis except for php 5.3
robfrawley Jun 6, 2017
d586411
Merge pull request #945 from robfrawley/bugfix-travis
cedricziel Jun 6, 2017
a045553
Typo at log message
Jun 8, 2017
f57164f
return filter function String
imanalopher Jun 17, 2017
6e43896
Merge pull request #951 from imanalopher/1.0
cedricziel Jun 20, 2017
5c9c7e8
Merge pull request #947 from you-ser/1.0
cedricziel Jun 20, 2017
45835f4
Merge pull request #940 from robfrawley/feature-remove-symfony-33-fro…
cedricziel Jun 20, 2017
6e8ec6d
add chain loader implementation
robfrawley Jun 20, 2017
6e1be77
Merge pull request #953 from robfrawley/feature-add-chain-data-loader
cedricziel Jun 28, 2017
2301d94
add chain loader documentation
robfrawley Jun 29, 2017
ef1d95a
Merge pull request #957 from robfrawley/feature-document-chain-loader
cedricziel Jun 29, 2017
6d82293
add support for latest imagine library version 0.7.0
robfrawley Jun 30, 2017
f65a530
Merge pull request #939 from robfrawley/feature-use-version-id-instea…
robfrawley Jul 8, 2017
309690d
add resample filter implementation
robfrawley May 22, 2017
c13bb62
Merge pull request #958 from robfrawley/feature-use-latest-imagine-lib
alexwilson Jul 9, 2017
52eeb9b
Pass roots to LocatorInterface directly instead
rpkamp May 20, 2017
2dffd96
cleanup of pr
robfrawley Jul 21, 2017
5e321d2
Modify some PHP Annotations
Jul 27, 2017
22d874c
enable functional testing of resample filter with both imagick and gm…
robfrawley Aug 4, 2017
23e79a7
add comment about supported method signitures for FileSystemLoader::_…
robfrawley Aug 4, 2017
39a3c14
Allow to configure the HTTP response code for redirects
lstrojny Aug 4, 2017
3413e7c
Added support for centerright and centerleft position to the Backgrou…
cmodijk Aug 11, 2017
a4fd34a
Merge pull request #965 from imanalopher/1.0
cedricziel Aug 21, 2017
8e636c6
Merge pull request #974 from JCID/patch-1
cedricziel Aug 28, 2017
145133a
Updated the docs for #974
cmodijk Aug 28, 2017
627b7bd
Use more intuitive order of positions
cedricziel Aug 28, 2017
1c9811e
cleanup cache resolve command, add forced resolve, prittify and detai…
robfrawley Jul 27, 2017
abc60cc
Merge branch '1.0' into pr-937
robfrawley Aug 31, 2017
f10ae8e
Merge pull request #941 from robfrawley/feature-add-resolution-filter
robfrawley Aug 31, 2017
d62b2d9
Merge pull request #970 from lstrojny/dev/configurable-redirect-respo…
robfrawley Aug 31, 2017
67b058c
Merge pull request #967 from robfrawley/feature-add-force-resolve-com…
robfrawley Aug 31, 2017
8c22844
Merge pull request #963 from robfrawley/pr-937
robfrawley Aug 31, 2017
78c0dd3
fix filesystem loader deprecation message
robfrawley Aug 31, 2017
0256c89
Merge pull request #982 from robfrawley/bugfix-fix-filesystem-loader-…
robfrawley Aug 31, 2017
a3bde59
ready 1.9.0 release
robfrawley Aug 31, 2017
f0d636d
reformat changelog and add lead/description to upgrade and changelog
robfrawley Aug 31, 2017
c72e914
Merge pull request #983 from robfrawley/release-1.9.0
robfrawley Sep 2, 2017
2b9f4e6
fix typo in upgrade file
robfrawley Sep 2, 2017
0595999
Merge pull request #979 from cmodijk/patch-1
robfrawley Sep 3, 2017
6b166b4
fix and amend console resolve and remove commands
robfrawley Sep 8, 2017
3084c77
Merge pull request #991 from robfrawley/feature-bugfix-console-commands
robfrawley Sep 9, 2017
4971bf8
Fix nested level of bucket parameter
bocharsky-bw Sep 18, 2017
4a69a44
test with php 7.2
dbu Nov 18, 2017
713e36f
Merge pull request #1009 from liip/php-72
dbu Nov 18, 2017
e2c8c52
create fixed filter
peter-gribanov Nov 28, 2017
41cb286
use old array format
peter-gribanov Nov 28, 2017
a69ac5b
Update png-quant.rst
qkdreyer Dec 6, 2017
09ccee5
Merge pull request #1020 from qkdreyer/patch-1
lsmith77 Dec 10, 2017
8a25c70
Update png-quant.rst
bruno-ds Dec 20, 2017
153808a
Merge pull request #1026 from bruno-ds/patch-1
lsmith77 Jan 20, 2018
44ea861
Merge pull request #996 from bocharsky-bw/patch-1
lsmith77 Jan 20, 2018
82ce051
Merge remote-tracking branch 'liip/1.0' into 1.0
peter-gribanov Jan 22, 2018
28bdb71
Merge branch '1.0' into fixed_filter
peter-gribanov Jan 22, 2018
9377ac0
add docs for fixed size filter
peter-gribanov Jan 22, 2018
7cb259a
fix annotation
auipga Mar 7, 2018
376139c
Just use inheritdoc tag
cedricziel Mar 7, 2018
199cc53
Merge pull request #1072 from auipga/patch-1
maximgubar May 8, 2018
d24e34c
Merge pull request #1015 from peter-gribanov/fixed_filter
maximgubar Jul 23, 2018
6683cac
Merge branch '1.0' into merge_from_1_to_2
franmomu Aug 2, 2019
33c290f
fix tests
franmomu Aug 3, 2019
db8c347
apply cs fixer
franmomu Aug 3, 2019
fe8a2f0
increase phpunit-bridge dependecy to 4.2
franmomu Aug 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ matrix:
env:
- SYMFONY_VERSION=4.0.*
- COMPOSER_FLAGS="--prefer-lowest"
- DEPENDENCIES="symfony/phpunit-bridge:^4"
- php: 7.2
- php: 7.2
env: SYMFONY_VERSION=3.4.*
- php: 7.2
env: SYMFONY_VERSION=4.0.*
- php: 7.2
env:
- DEPENDENCIES="symfony/phpunit-bridge:^4"
- DEPENDENCIES="symfony/phpunit-bridge:^4.2"
- COMPOSER_UPDATE_FLAGS="--no-dev"
- php: 7.2
env:
Expand Down
6 changes: 3 additions & 3 deletions Async/ResolveCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ResolveCache implements \JsonSerializable
private $path;

/**
* @var array|null|\string[]
* @var array|\string[]|null
*/
private $filters;

Expand Down Expand Up @@ -52,7 +52,7 @@ public function getPath(): string
}

/**
* @return null|\string[]
* @return \string[]|null
*/
public function getFilters()
{
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function jsonDeserialize(string $json): self
throw new LogicException('The message does not contain "path" but it is required.');
}

if (!(null === $data['filters'] || is_array($data['filters']))) {
if (!(null === $data['filters'] || \is_array($data['filters']))) {
throw new LogicException('The message filters could be either null or array.');
}

Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/ChainLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static function getLoaderExceptionMessage(string $path, array $exception
return vsprintf('Source image not resolvable "%s" using "%s" %d loaders (internal exceptions: %s).', [
$path,
implode(', ', $loaders),
count($loaders),
\count($loaders),
implode(', ', $exceptions),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct($wrapperPrefix, $context = null)
{
$this->wrapperPrefix = $wrapperPrefix;

if ($context && !is_resource($context)) {
if ($context && !\is_resource($context)) {
throw new \InvalidArgumentException('The given context is no valid resource.');
}

Expand Down
2 changes: 1 addition & 1 deletion Binary/Locator/FileSystemLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function sanitizeAbsolutePath(string $path): string
return 0 === mb_strpos($path, $root);
});

if (0 === count($roots)) {
if (0 === \count($roots)) {
throw new NotLoadableException(
sprintf('Source image invalid "%s" as it is outside of the defined root path(s) "%s"', $path, implode(':', $this->roots))
);
Expand Down
2 changes: 1 addition & 1 deletion Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function filterRuntimeAction(Request $request, $hash, $path, $filter)
$resolver = $request->get('resolver');
$runtimeConfig = $request->query->get('filters', []);

if (!is_array($runtimeConfig)) {
if (!\is_array($runtimeConfig)) {
throw new NotFoundHttpException(sprintf('Filters must be an array. Value was "%s"', $runtimeConfig));
}

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/FiltersCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.filter.loader');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
$manager = $container->getDefinition('liip_imagine.filter.manager');

foreach ($tags as $id => $tag) {
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/LoadersCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.binary.loader');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.data.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.data.manager')) {
$manager = $container->getDefinition('liip_imagine.data.manager');

foreach ($tags as $id => $tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function process(ContainerBuilder $container): void
*/
protected function isExifExtensionLoaded(): bool
{
return extension_loaded('exif');
return \extension_loaded('exif');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.filter.post_processor');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
$manager = $container->getDefinition('liip_imagine.filter.manager');

foreach ($tags as $id => $tag) {
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/ResolversCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.cache.resolver');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.cache.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.cache.manager')) {
$manager = $container->getDefinition('liip_imagine.cache.manager');

foreach ($tags as $id => $tag) {
Expand Down
10 changes: 5 additions & 5 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ public function getConfigTreeBuilder()
$v['loaders'] = [];
}

if (false === is_array($v['loaders'])) {
if (false === \is_array($v['loaders'])) {
throw new \LogicException('Loaders has to be array');
}

if (false === array_key_exists('default', $v['loaders'])) {
if (false === \array_key_exists('default', $v['loaders'])) {
$v['loaders']['default'] = ['filesystem' => null];
}

if (empty($v['resolvers'])) {
$v['resolvers'] = [];
}

if (false === is_array($v['resolvers'])) {
if (false === \is_array($v['resolvers'])) {
throw new \LogicException('Resolvers has to be array');
}

if (false === array_key_exists('default', $v['resolvers'])) {
if (false === \array_key_exists('default', $v['resolvers'])) {
$v['resolvers']['default'] = ['web_path' => null];
}

Expand All @@ -107,7 +107,7 @@ public function getConfigTreeBuilder()
->scalarNode('driver')->defaultValue('gd')
->validate()
->ifTrue(function ($v) {
return !in_array($v, ['gd', 'imagick', 'gmagick'], true);
return !\in_array($v, ['gd', 'imagick', 'gmagick'], true);
})
->thenInvalid('Invalid imagine driver specified: %s')
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function resolveDataRoots(array $staticPaths, array $config, ContainerBu
$resourcePaths = [];

foreach ($this->getBundleResourcePaths($container) as $name => $path) {
if (('whitelist' === $config['access_control_type']) === in_array($name, $config['access_control_list'], true) && is_dir($path)) {
if (('whitelist' === $config['access_control_type']) === \in_array($name, $config['access_control_list'], true) && is_dir($path)) {
$resourcePaths[$name] = $path;
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ private function getBundlePathsUsingNamedObj(array $classes)
throw new InvalidArgumentException(sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), null, $exception);
}

$paths[$r->getShortName()] = dirname($r->getFileName());
$paths[$r->getShortName()] = \dirname($r->getFileName());
}

return $paths;
Expand Down
2 changes: 1 addition & 1 deletion Events/CacheResolveEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CacheResolveEvent extends Event
*
* @param string $path
* @param string $filter
* @param null|string $url
* @param string|null $url
*/
public function __construct($path, $filter, $url = null)
{
Expand Down
18 changes: 18 additions & 0 deletions Exception/Imagine/Filter/LoadFilterException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Exception\Imagine\Filter;

use Liip\ImagineBundle\Exception\ExceptionInterface;

class LoadFilterException extends \RuntimeException implements ExceptionInterface
{
}
4 changes: 2 additions & 2 deletions Imagine/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ public function remove($paths = null, $filters = null)
{
if (null === $filters) {
$filters = array_keys($this->filterConfig->all());
} elseif (!is_array($filters)) {
} elseif (!\is_array($filters)) {
$filters = [$filters];
}
if (!is_array($paths)) {
if (!\is_array($paths)) {
$paths = [$paths];
}

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Cache/Resolver/AbstractFilesystemResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function getRequest()
protected function makeFolder($dir)
{
if (!is_dir($dir)) {
$parent = dirname($dir);
$parent = \dirname($dir);
try {
$this->makeFolder($parent);
$this->filesystem->mkdir($dir);
Expand Down
4 changes: 2 additions & 2 deletions Imagine/Cache/Resolver/CacheResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected function saveToCache($cacheKey, $content)
if ($this->cache->contains($indexKey)) {
$index = (array) $this->cache->fetch($indexKey);

if (!in_array($cacheKey, $index, true)) {
if (!\in_array($cacheKey, $index, true)) {
$index[] = $cacheKey;
}
} else {
Expand All @@ -236,7 +236,7 @@ protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'global_prefix' => 'liip_imagine.resolver_cache',
'prefix' => get_class($this->resolver),
'prefix' => \get_class($this->resolver),
'index_key' => 'index',
]);

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Filter/FilterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(array $filters = [])
*/
public function get($filter)
{
if (false === array_key_exists($filter, $this->filters)) {
if (false === \array_key_exists($filter, $this->filters)) {
throw new NonExistingFilterException(sprintf('Could not find configuration for a filter: %s', $filter));
}

Expand Down
4 changes: 2 additions & 2 deletions Imagine/Filter/FilterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private function sanitizeFilters(array $filters): array
return isset($this->loaders[$name]);
}, ARRAY_FILTER_USE_KEY);

if (count($filters) !== count($sanitized)) {
if (\count($filters) !== \count($sanitized)) {
throw new \InvalidArgumentException(sprintf('Could not find filter(s): %s', implode(', ', array_map(function (string $name): string {
return sprintf('"%s"', $name);
}, array_diff(array_keys($filters), array_keys($sanitized))))));
Expand All @@ -241,7 +241,7 @@ private function sanitizePostProcessors(array $processors): array
return isset($this->postProcessors[$name]);
}, ARRAY_FILTER_USE_KEY);

if (count($processors) !== count($sanitized)) {
if (\count($processors) !== \count($sanitized)) {
throw new \InvalidArgumentException(sprintf('Could not find post processor(s): %s', implode(', ', array_map(function (string $name): string {
return sprintf('"%s"', $name);
}, array_diff(array_keys($processors), array_keys($sanitized))))));
Expand Down
2 changes: 1 addition & 1 deletion Imagine/Filter/Loader/AutoRotateFilterLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ private function getOrientation(ImageInterface $image)
*/
private function isFlipped($orientation)
{
return in_array((int) $orientation, [2, 4, 5, 7], true);
return \in_array((int) $orientation, [2, 4, 5, 7], true);
}
}
8 changes: 8 additions & 0 deletions Imagine/Filter/Loader/BackgroundFilterLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ public function load(ImageInterface $image, array $options = [])
$x = 0;
$y = ($height - $image->getSize()->getHeight()) / 2;
break;
case 'centerright':
$x = $width - $image->getSize()->getWidth();
$y = ($height - $image->getSize()->getHeight()) / 2;
break;
case 'center':
$x = ($width - $image->getSize()->getWidth()) / 2;
$y = ($height - $image->getSize()->getHeight()) / 2;
break;
case 'centerleft':
$x = 0;
$y = ($height - $image->getSize()->getHeight()) / 2;
break;
case 'right':
$x = $width - $image->getSize()->getWidth();
$y = ($height - $image->getSize()->getHeight()) / 2;
Expand Down
65 changes: 65 additions & 0 deletions Imagine/Filter/Loader/FixedFilterLoader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Imagine\Filter\Loader;

use Imagine\Filter\Basic\Crop;
use Imagine\Filter\Basic\Resize;
use Imagine\Image\Box;
use Imagine\Image\ImageInterface;
use Imagine\Image\Point;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Fixed size filter.
*
* @author Robbe Clerckx <https://github.com/robbeman>
*/
class FixedFilterLoader implements LoaderInterface
{
/**
* @param ImageInterface $image
* @param array $options
*
* @return ImageInterface
*/
public function load(ImageInterface $image, array $options = [])
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setRequired(['width', 'height']);
$options = $optionsResolver->resolve($options);

// get the original image size and create a crop box
$size = $image->getSize();
$box = new Box($options['width'], $options['height']);

// determine scale
if ($size->getWidth() / $size->getHeight() > $box->getWidth() / $box->getHeight()) {
$size = $size->heighten($box->getHeight());
} else {
$size = $size->widen($box->getWidth());
}

// define filters
$resize = new Resize($size);
$origin = new Point(
floor(($size->getWidth() - $box->getWidth()) / 2),
floor(($size->getHeight() - $box->getHeight()) / 2)
);
$crop = new Crop($origin, $box);

// apply filters to image
$image = $resize->apply($image);
$image = $crop->apply($image);

return $image;
}
}