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
[Filters] [Config] [DI] Add Filter configuration class as public service #1098
Changes from 13 commits
6b41c3b
11c0c12
6a8cff3
add533f
95db82b
d907670
e213124
851a38b
27c8794
5c4d68f
e306612
db0a518
d6c599f
6906000
4ea4acc
ebc5744
02e4022
c4923d0
c564a62
9971029
36d7843
91bfe94
9df4d4b
be890e3
8458b37
6613b61
cdab3b8
f8cdfb7
2a397ae
f1ed641
0624a2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ public function locate(string $path): string | |
*/ | ||
protected function generateAbsolutePath(string $root, string $path): ?string | ||
{ | ||
if (false !== $absolute = realpath($root.DIRECTORY_SEPARATOR.$path)) { | ||
if (false !== $absolute = realpath($root.\DIRECTORY_SEPARATOR.$path)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the backslashes here? |
||
return $absolute; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class AutoRotate implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @param string $name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets remove this, its redundant |
||
*/ | ||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class Background implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $color; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $transparency; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $position; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $size; | ||
|
||
/** | ||
* @param string $name | ||
* @param string|null $color | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am ok with using a string for the $color, but we should explain here what it is. RRGGBB? with optional transparency? |
||
* @param string|null $transparency | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should state the range of this. 0 to 100? or 0 to 1? or something else? |
||
* @param string|null $position | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is that a list of keywords like TOP|LEFT|BOTTOM|RIGHT, or something else? |
||
* @param array $size | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keys x and y? or do we use a value object for this? |
||
*/ | ||
public function __construct( | ||
string $name, | ||
string $color = null, | ||
string $transparency = null, | ||
string $position = null, | ||
array $size = [] | ||
) { | ||
$this->name = $name; | ||
$this->color = $color; | ||
$this->transparency = $transparency; | ||
$this->position = $position; | ||
$this->size = $size; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Max, this is wrong. If color is optional - use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the hint, will refactor. |
||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getColor(): string | ||
{ | ||
return $this->color; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getTransparency(): string | ||
{ | ||
return $this->transparency; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getPosition() | ||
{ | ||
return $this->position; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getSize(): array | ||
{ | ||
return $this->size; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class Crop implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $start; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $size; | ||
|
||
/** | ||
* @param string $name | ||
* @param array $start start coordinates {x,y} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not provide value object for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea, will add it |
||
* @param array $size size parameters {width, height} | ||
*/ | ||
public function __construct(string $name, array $start, array $size) | ||
{ | ||
$this->name = $name; | ||
$this->start = $start; | ||
$this->size = $size; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getStart(): array | ||
{ | ||
return $this->start; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getSize(): array | ||
{ | ||
return $this->size; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class Downscale implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $max; | ||
|
||
/** | ||
* @var float | ||
*/ | ||
private $by; | ||
|
||
/** | ||
* @param string $name | ||
* @param array $max desired max dimensions {width, height} | ||
* @param float $by sets the "ratio multiple" which initiates a proportional scale operation computed by multiplying all image sides by this value | ||
*/ | ||
public function __construct(string $name, array $max = [], float $by = null) | ||
{ | ||
$this->name = $name; | ||
$this->max = $max; | ||
$this->by = $by; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getMax(): array | ||
{ | ||
return $this->max; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getBy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
return $this->by; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class Flip implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $axis; | ||
|
||
/** | ||
* @param string $name | ||
* @param string $axis possible values are: "x", "horizontal", "y", or "vertical" | ||
*/ | ||
public function __construct(string $name, string $axis) | ||
{ | ||
$this->name = $name; | ||
$this->axis = $axis; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we validate the values? does imagine provide constants for these? |
||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAxis(): string | ||
{ | ||
return $this->axis; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?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\Config\Filter\Type; | ||
|
||
use Liip\ImagineBundle\Config\FilterInterface; | ||
|
||
final class Grayscale implements FilterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @param string $name | ||
*/ | ||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the backslashes here?