Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

BorderFilterLoader.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader;
8
9 use Imagine\Filter\Advanced\Border;
10 use Imagine\Image\ImageInterface;
11 use Imagine\Exception\InvalidArgumentException;
12 use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface;
13
20 class BorderFilterLoader implements LoaderInterface
21 {
22 const DEFAULT_BORDER_COLOR = '#000';
23
24 public function load(ImageInterface $image, array $options = [])
25 {
26 $optionsCount = count($options);
27 if ($optionsCount < 2) {
28 throw new InvalidArgumentException('Invalid options for border filter. You must provide array(width, height)');
29 }
30
31 $color = static::DEFAULT_BORDER_COLOR;
32 if ($optionsCount > 2) {
33 list($width, $height, $color) = $options;
34 } else {
35 list($width, $height) = $options;
36 }
37
38 $border = new Border($image->palette()->color($color), $width, $height);
39
40 return $border->apply($image);
41 }
42 }
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\BorderFilterLoader
Loader for border filter.
Definition: BorderFilterLoader.php:21
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\BorderFilterLoader\DEFAULT_BORDER_COLOR
const DEFAULT_BORDER_COLOR
Definition: BorderFilterLoader.php:22
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\BorderFilterLoader\load
load(ImageInterface $image, array $options=[])
Definition: BorderFilterLoader.php:24
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader
Definition: BorderFilterLoader.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.