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 #1011

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
4a69a44
test with php 7.2
dbu Nov 18, 2017
713e36f
Merge pull request #1009 from liip/php-72
dbu Nov 18, 2017
9186026
solve conflicts from 1.0 to 2.0 branch
dbu Nov 18, 2017
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
Expand Up @@ -6,6 +6,7 @@ language: php

php:
- 7.1
- 7.2
- nightly

cache:
Expand Down Expand Up @@ -36,5 +37,3 @@ script:

after_script:
- bash ./.travis/exec-after.bash

...
64 changes: 64 additions & 0 deletions Binary/Loader/ChainLoader.php
@@ -0,0 +1,64 @@
<?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\Binary\Loader;

use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException;

class ChainLoader implements LoaderInterface
{
/**
* @var LoaderInterface[]
*/
private $loaders;

/**
* @param LoaderInterface[] $loaders
*/
public function __construct(array $loaders)
{
$this->loaders = array_filter($loaders, function ($loader) {
return $loader instanceof LoaderInterface;
});
}

/**
* {@inheritdoc}
*/
public function find($path)
{
foreach ($this->loaders as $loader) {
try {
return $loader->find($path);
} catch (\Exception $loaderException) {
// handle exception later
}
}

throw new NotLoadableException(vsprintf('Source image not resolvable "%s" using "%s" loaders.', array(
$path,
$this->getLoaderNamesString(),
)));
}

/**
* @return string
*/
private function getLoaderNamesString()
{
$names = array();
foreach ($this->loaders as $n => $l) {
$names[] = sprintf('%s=[%s]', $n, get_class($l));
}

return implode(':', $names);
}
}
15 changes: 15 additions & 0 deletions Binary/Locator/FileSystemLocator.php
Expand Up @@ -24,6 +24,16 @@ class FileSystemLocator implements LocatorInterface
private $roots = [];

/**
* @param string[] $roots
*/
public function __construct(array $roots = array())
{
$this->roots = array_map(array($this, 'sanitizeRootPath'), $roots);
}

/**
* @deprecated Since version 0.9.0, use __construct(array $roots) instead
*
* @param array[] $options
*/
public function setOptions(array $options = [])
Expand All @@ -37,6 +47,11 @@ public function setOptions(array $options = [])
throw new InvalidArgumentException(sprintf('Invalid options provided to %s()', __METHOD__), null, $e);
}

@trigger_error(
sprintf('%s() is deprecated. Pass the data roots to the constructor instead.', __METHOD__),
E_USER_DEPRECATED
);

$this->roots = array_map([$this, 'sanitizeRootPath'], (array) $options['roots']);
}

Expand Down
1,260 changes: 720 additions & 540 deletions CHANGELOG.md

Large diffs are not rendered by default.

242 changes: 242 additions & 0 deletions Command/AbstractCacheCommand.php
@@ -0,0 +1,242 @@
<?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\Command;

use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Liip\ImagineBundle\Imagine\Data\DataManager;
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

abstract class AbstractCacheCommand extends ContainerAwareCommand
{
/**
* @var OutputInterface
*/
protected $output;

/**
* @var bool
*/
protected $machineReadable;

/**
* @var int
*/
protected $actionFailures;

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function initializeInstState(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->machineReadable = $input->getOption('machine-readable');
$this->actionFailures = 0;
}

/**
* @param InputInterface $input
*
* @return array
*/
protected function resolveFilters(InputInterface $input)
{
$filters = $input->getOption('filter');

if (0 !== count($deprecated = $input->getOption('filters'))) {
$filters = array_merge($filters, $deprecated);
@trigger_error('The --filters option was deprecated in 1.9.0 and removed in 2.0.0. Use the --filter option instead.', E_USER_DEPRECATED);
}

if (0 === count($filters) && 0 === count($filters = array_keys($this->getFilterManager()->getFilterConfiguration()->all()))) {
$this->output->writeln('<bg=red;fg=white> [ERROR] You do not have any configured filters available. </>');
}

return $filters;
}

/**
* @param string $command
*/
protected function writeCommandHeading($command)
{
if ($this->machineReadable) {
return;
}

$title = sprintf('[liip/imagine-bundle] %s Image Caches', ucfirst($command));
$this->writeNewline();
$this->output->writeln(sprintf('<info>%s</info>', $title));
$this->output->writeln(str_repeat('=', strlen($title)));
$this->writeNewline();
}

/**
* @param string[] $filters
* @param string[] $targets
* @param bool $glob
*/
protected function writeResultSummary(array $filters, array $targets, $glob = false)
{
if ($this->machineReadable) {
return;
}

$targetCount = count($targets);
$filterCount = count($filters);
$actionCount = ($glob ? $filterCount : ($filterCount * $targetCount)) - $this->actionFailures;

$this->writeNewline();
$this->output->writeln(vsprintf('<fg=black;bg=green> Completed %d %s (%d %s / %s %s) </>%s', array(
$actionCount,
$this->getPluralized($actionCount, 'operation'),
$filterCount,
$this->getPluralized($filterCount, 'filter'),
$glob ? '?' : $targetCount,
$this->getPluralized($targetCount, 'image'),
$this->getResultSummaryFailureMarkup(),
)));
$this->writeNewline();
}

/**
* @param string $filter
* @param string|null $target
*/
protected function writeActionStart($filter, $target = null)
{
if (!$this->machineReadable) {
$this->output->write(' - ');
}

$this->output->write(sprintf('%s[%s] ', $target ?: '*', $filter));
}

/**
* @param string $result
* @param bool $continued
*/
protected function writeActionResult($result, $continued = true)
{
$this->output->write($continued ? sprintf('%s: ', $result) : $result);

if (!$continued) {
$this->writeNewline();
}
}

/**
* @param string $detail
*/
protected function writeActionDetail($detail)
{
$this->output->write($detail);
$this->writeNewline();
}

/**
* @param \Exception $exception
*/
protected function writeActionException(\Exception $exception)
{
$this->writeActionResult('failure');
$this->writeActionDetail($exception->getMessage());
++$this->actionFailures;
}

/**
* @return int
*/
protected function getReturnCode()
{
return 0 === $this->actionFailures ? 0 : 255;
}

/**
* @return CacheManager
*/
protected function getCacheManager()
{
static $manager;

if (null === $manager) {
$manager = $this->getContainer()->get('liip_imagine.cache.manager');
}

return $manager;
}

/**
* @return FilterManager
*/
protected function getFilterManager()
{
static $manager;

if (null === $manager) {
$manager = $this->getContainer()->get('liip_imagine.filter.manager');
}

return $manager;
}

/**
* @return DataManager
*/
protected function getDataManager()
{
static $manager;

if (null === $manager) {
$manager = $this->getContainer()->get('liip_imagine.data.manager');
}

return $manager;
}

/**
* @param int $count
*/
private function writeNewline($count = 1)
{
$this->output->write(str_repeat(PHP_EOL, $count));
}

/**
* @param int $size
* @param string $word
*
* @return string
*/
private function getPluralized($size, $word)
{
return 1 === $size ? $word : sprintf('%ss', $word);
}

/**
* @return string
*/
private function getResultSummaryFailureMarkup()
{
if (0 === $this->actionFailures) {
return '';
}

return vsprintf(' <fg=white;bg=red;options=bold> encountered %s %s </>', array(
$this->actionFailures,
$this->getPluralized($this->actionFailures, 'failure'),
));
}
}