init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
3
vendor/gregwar/image-bundle/.gitignore
vendored
Normal file
3
vendor/gregwar/image-bundle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
composer.lock
|
||||
vendor
|
||||
/.php_cs.cache
|
||||
9
vendor/gregwar/image-bundle/.php_cs
vendored
Normal file
9
vendor/gregwar/image-bundle/.php_cs
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once './vendor/autoload.php';
|
||||
|
||||
use SLLH\StyleCIBridge\ConfigBridge;
|
||||
|
||||
return ConfigBridge::create()
|
||||
->setUsingCache(true)
|
||||
;
|
||||
13
vendor/gregwar/image-bundle/.styleci.yml
vendored
Normal file
13
vendor/gregwar/image-bundle/.styleci.yml
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
preset: symfony
|
||||
|
||||
enabled:
|
||||
- align_double_arrow
|
||||
- newline_after_open_tag
|
||||
- ordered_use
|
||||
- long_array_syntax
|
||||
- php_unit_construct
|
||||
- php_unit_strict
|
||||
|
||||
disabled:
|
||||
- unalign_double_arrow
|
||||
- unalign_equals
|
||||
34
vendor/gregwar/image-bundle/DependencyInjection/Configuration.php
vendored
Normal file
34
vendor/gregwar/image-bundle/DependencyInjection/Configuration.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @Author: Michał Kurzeja, Accesto
|
||||
* User: michal
|
||||
* Date: 24.09.13
|
||||
* Time: 10:18
|
||||
*/
|
||||
namespace Gregwar\ImageBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('gregwar_image');
|
||||
$rootNode = method_exists(TreeBuilder::class, 'getRootNode') ?
|
||||
$treeBuilder->getRootNode() : $treeBuilder->root('gregwar_image');
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('cache_dir')->defaultValue('cache')->end()
|
||||
->scalarNode('cache_dir_mode')->defaultNull()->example('0755')->end()
|
||||
->booleanNode('throw_exception')->defaultFalse()->end()
|
||||
->scalarNode('fallback_image')->defaultNull()->end()
|
||||
->scalarNode('web_dir')->defaultValue('%kernel.root_dir%/../web')->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
31
vendor/gregwar/image-bundle/DependencyInjection/GregwarImageExtension.php
vendored
Normal file
31
vendor/gregwar/image-bundle/DependencyInjection/GregwarImageExtension.php
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Gregwar\ImageBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* Loading configuration.
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class GregwarImageExtension extends Extension
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('gregwar_image.cache_dir', $config['cache_dir']);
|
||||
$container->setParameter('gregwar_image.cache_dir_mode', $config['cache_dir_mode']);
|
||||
$container->setParameter('gregwar_image.throw_exception', $config['throw_exception']);
|
||||
$container->setParameter('gregwar_image.fallback_image', $config['fallback_image']);
|
||||
$container->setParameter('gregwar_image.web_dir', $config['web_dir']);
|
||||
|
||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
}
|
||||
87
vendor/gregwar/image-bundle/Extensions/ImageTwig.php
vendored
Normal file
87
vendor/gregwar/image-bundle/Extensions/ImageTwig.php
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace Gregwar\ImageBundle\Extensions;
|
||||
|
||||
use Gregwar\ImageBundle\Services\ImageHandling;
|
||||
|
||||
/**
|
||||
* ImageTwig extension.
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
* @author bzikarsky <benjamin.zikarsky@perbility.de>
|
||||
*/
|
||||
class ImageTwig extends \Twig_Extension
|
||||
{
|
||||
/**
|
||||
* @var ImageHandling
|
||||
*/
|
||||
private $imageHandling;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $webDir;
|
||||
|
||||
/**
|
||||
* @param ImageHandling $imageHandling
|
||||
* @param string $webDir
|
||||
*/
|
||||
public function __construct(ImageHandling $imageHandling, $webDir)
|
||||
{
|
||||
$this->imageHandling = $imageHandling;
|
||||
$this->webDir = $webDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('image', array($this, 'image'), array('is_safe' => array('html'))),
|
||||
new \Twig_SimpleFunction('new_image', array($this, 'newImage'), array('is_safe' => array('html'))),
|
||||
new \Twig_SimpleFunction('web_image', array($this, 'webImage'), array('is_safe' => array('html'))),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function webImage($path)
|
||||
{
|
||||
$directory = $this->webDir.'/';
|
||||
|
||||
return $this->imageHandling->open($directory.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function image($path)
|
||||
{
|
||||
return $this->imageHandling->open($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $width
|
||||
* @param string $height
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function newImage($width, $height)
|
||||
{
|
||||
return $this->imageHandling->create($width, $height);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'image';
|
||||
}
|
||||
}
|
||||
9
vendor/gregwar/image-bundle/GregwarImageBundle.php
vendored
Normal file
9
vendor/gregwar/image-bundle/GregwarImageBundle.php
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Gregwar\ImageBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class GregwarImageBundle extends Bundle
|
||||
{
|
||||
}
|
||||
61
vendor/gregwar/image-bundle/ImageHandler.php
vendored
Normal file
61
vendor/gregwar/image-bundle/ImageHandler.php
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Gregwar\ImageBundle;
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
/**
|
||||
* Image manipulation class.
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class ImageHandler extends Image
|
||||
{
|
||||
protected $fileCallback = null;
|
||||
|
||||
/**
|
||||
* @param null $originalFile
|
||||
* @param null $width
|
||||
* @param null $height
|
||||
* @param bool $throwException
|
||||
*/
|
||||
public function __construct($originalFile = null, $width = null, $height = null, $throwException = null, $fallbackImage = null)
|
||||
{
|
||||
parent::__construct($originalFile, $width, $height);
|
||||
|
||||
$this->useFallback(!$throwException);
|
||||
$this->setFallback($fallbackImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the callback to call to compute the new filename.
|
||||
*/
|
||||
public function setFileCallback($fileCallback)
|
||||
{
|
||||
$this->fileCallback = $fileCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* When processing the filename, call the callback.
|
||||
*/
|
||||
protected function getFilename($filename)
|
||||
{
|
||||
$callback = $this->fileCallback;
|
||||
|
||||
if (null === $callback || substr($filename, 0, 1) == '/') {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
return $callback($filename);
|
||||
}
|
||||
|
||||
public function save($file, $type = 'guess', $quality = 80)
|
||||
{
|
||||
return parent::save($file, $type, $quality);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return parent::__toString();
|
||||
}
|
||||
}
|
||||
19
vendor/gregwar/image-bundle/LICENSE
vendored
Normal file
19
vendor/gregwar/image-bundle/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) <2012> Grégoire Passault
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
2
vendor/gregwar/image-bundle/Makefile
vendored
Normal file
2
vendor/gregwar/image-bundle/Makefile
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cs:
|
||||
php-cs-fixer fix --verbose
|
||||
190
vendor/gregwar/image-bundle/README.md
vendored
Normal file
190
vendor/gregwar/image-bundle/README.md
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
Gregwar's ImageBundle
|
||||
=====================
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YUXRLWHQSWS6L)
|
||||
|
||||
`GregwarImageBundle` provides easy Image manipulation and API for Symfony2 and Twig
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
### Step 1: Download the GregwarImageBundle
|
||||
|
||||
***Using the vendors script***
|
||||
|
||||
Add the following lines to your `deps` file:
|
||||
|
||||
```
|
||||
[GregwarImageBundle]
|
||||
git=http://github.com/Gregwar/ImageBundle.git
|
||||
target=/bundles/Gregwar/ImageBundle
|
||||
```
|
||||
|
||||
Now, run the vendors script to download the bundle:
|
||||
|
||||
``` bash
|
||||
$ php bin/vendors install
|
||||
```
|
||||
|
||||
***Using submodules***
|
||||
|
||||
If you prefer instead to use git submodules, then run the following:
|
||||
|
||||
``` bash
|
||||
$ git submodule add git://github.com/Gregwar/ImageBundle.git vendor/bundles/Gregwar/ImageBundle
|
||||
$ git submodule update --init
|
||||
```
|
||||
|
||||
***Using Composer***
|
||||
|
||||
Add the following to the "require" section of your `composer.json` file:
|
||||
|
||||
```
|
||||
"gregwar/image-bundle": "dev-master"
|
||||
```
|
||||
|
||||
You can also choose a version number, (tag, commit ...)
|
||||
|
||||
And update your dependencies
|
||||
|
||||
```
|
||||
php composer.phar update
|
||||
```
|
||||
|
||||
### Step 2: Configure the Autoloader
|
||||
|
||||
If you use composer, you can skip this step.
|
||||
|
||||
Add it to your `autoload.pp` :
|
||||
|
||||
```php
|
||||
<?php
|
||||
...
|
||||
'Gregwar' => __DIR__.'/../vendor/bundles',
|
||||
```
|
||||
|
||||
### Step 3: Enable the bundle
|
||||
|
||||
Registers the bundle in your `app/AppKernel.php`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
...
|
||||
public function registerBundles()
|
||||
{
|
||||
$bundles = array(
|
||||
...
|
||||
new Gregwar\ImageBundle\GregwarImageBundle(),
|
||||
...
|
||||
);
|
||||
...
|
||||
```
|
||||
|
||||
### Step 4: Configure the bundle and set up the directories
|
||||
|
||||
Adds the following configuration to your `app/config/config.yml`:
|
||||
|
||||
gregwar_image: ~
|
||||
|
||||
If you want to customize the cache directory name, you can specify it:
|
||||
|
||||
gregwar_image:
|
||||
cache_dir: my_cache_dir
|
||||
|
||||
Creates the cache directory and change the permissions so the web server can write
|
||||
in it:
|
||||
|
||||
mkdir web/cache
|
||||
chmod 777 web/cache
|
||||
|
||||
You can also enable the exception thrown if the given file does not exist:
|
||||
|
||||
gregwar_image:
|
||||
throw_exception: true
|
||||
|
||||
If you don't throw an exception, you can set the `fallback_image`, to set the
|
||||
image that should be rendered in this case:
|
||||
|
||||
gregwar_image:
|
||||
fallback_image: /path/to/your/fallback.jpg
|
||||
|
||||
If you have to change directories hierarchy or Web's name (e.g. web => public_html),
|
||||
you can set the `web_dir` to your new Web path:
|
||||
|
||||
gregwar_image:
|
||||
web_dir: %kernel.root_dir%/../../public_html
|
||||
|
||||
With Symfony Flex
|
||||
-----------------
|
||||
|
||||
With Symfony Flex architecture, you can create the ``config/packages/gregwar_image.yaml``
|
||||
file with the following contents:
|
||||
|
||||
gregwar_image:
|
||||
web_dir: %kernel.root_dir%/../public
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Basics
|
||||
------
|
||||
|
||||
This bundle is based on the [Gregwar's Image](http://github.com/Gregwar/Image) class and
|
||||
provides simple but powerful Twig extension. You can for instance use it this way:
|
||||
|
||||
```html
|
||||
<img src="{{ image('linux.jpg').resize(100,100).negate }}" />
|
||||
```
|
||||
|
||||
And that's all ! The helper will automatically create the cached file on-the-fly if it
|
||||
doesn't exists yet.
|
||||
|
||||
The available methods are the same as the [Gregwar's Image](http://github.com/Gregwar/Image).
|
||||
|
||||
You can also use the logical file names for bundle resources :
|
||||
|
||||
```html
|
||||
<img src="{{ image('@AcmeDemoBundle/Resources/images/linux.jpg').resize(100,100).negate }}" />
|
||||
```
|
||||
|
||||
If you use `web_image()` helper, the image file path will be prefixed by the `web/` absolute
|
||||
directory of your application:
|
||||
|
||||
```html
|
||||
<!-- The image some/image.jpg will be prefixed by web directory prefix -->
|
||||
<img src="{{ web_image('some/image.jpg').resize('10%') }}" />
|
||||
```
|
||||
|
||||
Using Image API
|
||||
---------------
|
||||
|
||||
The image instance provides also a simple API, you can call some methods to get informations
|
||||
about the handled image:
|
||||
|
||||
Image width: {{ image('linux.jpg').width }}px
|
||||
|
||||
Manipulating Image in Controllers
|
||||
---------------------------------
|
||||
|
||||
The Image Handler is accessible via a service called image.handling. So you can do in your
|
||||
controllers:
|
||||
|
||||
```php
|
||||
<?php
|
||||
...
|
||||
$this->get('image.handling')->open('linux.jpg')
|
||||
->grayscale()
|
||||
->rotate(12)
|
||||
->save('out.jpg')
|
||||
```
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
`GregwarImageBundle` needs [GD](http://php.net/gd)
|
||||
and [exif](http://php.net/exif) extension for PHP to be installed on the web server
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This bundle is under MIT license
|
||||
26
vendor/gregwar/image-bundle/Resources/config/services.yml
vendored
Normal file
26
vendor/gregwar/image-bundle/Resources/config/services.yml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
parameters:
|
||||
image.handling.class: Gregwar\ImageBundle\Services\ImageHandling
|
||||
image.handler.class: Gregwar\ImageBundle\ImageHandler
|
||||
|
||||
services:
|
||||
# Image handling factory
|
||||
image.handling:
|
||||
class: '%image.handling.class%'
|
||||
public: true
|
||||
arguments:
|
||||
- '%gregwar_image.cache_dir%'
|
||||
- '%gregwar_image.cache_dir_mode%'
|
||||
- '%image.handler.class%'
|
||||
- '@service_container'
|
||||
- '@assets.packages'
|
||||
- '@file_locator'
|
||||
- '%gregwar_image.throw_exception%'
|
||||
- '%gregwar_image.fallback_image%'
|
||||
|
||||
# Helper Twig
|
||||
twig.extension.image:
|
||||
class: Gregwar\ImageBundle\Extensions\ImageTwig
|
||||
arguments: ['@image.handling', '%gregwar_image.web_dir%']
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
166
vendor/gregwar/image-bundle/Services/ImageHandling.php
vendored
Normal file
166
vendor/gregwar/image-bundle/Services/ImageHandling.php
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
namespace Gregwar\ImageBundle\Services;
|
||||
|
||||
use Gregwar\ImageBundle\ImageHandler;
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* Image manipulation service.
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
* @author Sullivan Senechal <soullivaneuh@gmail.com>
|
||||
*/
|
||||
class ImageHandling
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cacheDirectory;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $cacheDirMode;
|
||||
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @var Packages
|
||||
*/
|
||||
private $assetsPackages;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $handlerClass;
|
||||
|
||||
/**
|
||||
* @var FileLocatorInterface|KernelInterface
|
||||
*/
|
||||
private $fileLocator;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $throwException;
|
||||
|
||||
/**
|
||||
* @param string $cacheDirectory
|
||||
* @param int $cacheDirMode
|
||||
* @param string $handlerClass
|
||||
* @param ContainerInterface $container
|
||||
* @param KernelInterface|FileLocatorInterface $fileLocator
|
||||
* @param bool $throwException
|
||||
* @param string $fallbackImage
|
||||
*/
|
||||
public function __construct($cacheDirectory, $cacheDirMode, $handlerClass, ContainerInterface $container, Packages $assetsPackages, $fileLocator, $throwException, $fallbackImage)
|
||||
{
|
||||
if (!$fileLocator instanceof FileLocatorInterface && $fileLocator instanceof KernelInterface) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Argument 5 passed to '.__METHOD__.' must be an instance of '.
|
||||
'Symfony\Component\Config\FileLocatorInterface or Symfony\Component\HttpKernel\KernelInterface.'
|
||||
);
|
||||
}
|
||||
|
||||
if ($fileLocator instanceof KernelInterface) {
|
||||
@trigger_error(
|
||||
'Pass Symfony\Component\HttpKernel\KernelInterface to '.__CLASS__.
|
||||
' is deprecated since version 2.1.0 and will be removed in 3.0.'.
|
||||
' Use Symfony\Component\Config\FileLocatorInterface instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
}
|
||||
|
||||
$this->cacheDirectory = $cacheDirectory;
|
||||
$this->cacheDirMode = intval($cacheDirMode);
|
||||
$this->handlerClass = $handlerClass;
|
||||
$this->container = $container;
|
||||
$this->assetsPackages = $assetsPackages;
|
||||
$this->fileLocator = $fileLocator;
|
||||
$this->throwException = $throwException;
|
||||
$this->fallbackImage = $fallbackImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a manipulable image instance.
|
||||
*
|
||||
* @param string $file the image path
|
||||
*
|
||||
* @return ImageHandler a manipulable image instance
|
||||
*/
|
||||
public function open($file)
|
||||
{
|
||||
if (strlen($file) >= 1 && $file[0] == '@') {
|
||||
try {
|
||||
if ($this->fileLocator instanceof FileLocatorInterface) {
|
||||
$file = $this->fileLocator->locate($file);
|
||||
} else {
|
||||
$this->fileLocator->locateResource($file);
|
||||
}
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
if ($this->throwException || false == $this->fallbackImage) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$file = $this->fallbackImage;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->createInstance($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new image.
|
||||
*
|
||||
* @param string $w the width
|
||||
* @param string $h the height
|
||||
*
|
||||
* @return ImageHandler a manipulable image instance
|
||||
*/
|
||||
public function create($w, $h)
|
||||
{
|
||||
return $this->createInstance(null, $w, $h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance defining the cache directory.
|
||||
*
|
||||
* @param string $file
|
||||
* @param string|null $w
|
||||
* @param string|null $h
|
||||
*
|
||||
* @return ImageHandler
|
||||
*/
|
||||
private function createInstance($file, $w = null, $h = null)
|
||||
{
|
||||
$container = $this->container;
|
||||
$webDir = $container->getParameter('gregwar_image.web_dir');
|
||||
|
||||
$handlerClass = $this->handlerClass;
|
||||
/** @var ImageHandler $image */
|
||||
$image = new $handlerClass($file, $w, $h, $this->throwException, $this->fallbackImage);
|
||||
|
||||
$image->setCacheDir($this->cacheDirectory);
|
||||
$image->setCacheDirMode($this->cacheDirMode);
|
||||
$image->setActualCacheDir($webDir.'/'.$this->cacheDirectory);
|
||||
|
||||
if ($container->has('templating.helper.assets')) {
|
||||
$image->setFileCallback(function ($file) use ($container) {
|
||||
return $container->get('templating.helper.assets')->getUrl($file);
|
||||
});
|
||||
} else {
|
||||
$image->setFileCallback(function ($file) use ($container) {
|
||||
return $this->assetsPackages->getUrl($file);
|
||||
});
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
35
vendor/gregwar/image-bundle/composer.json
vendored
Normal file
35
vendor/gregwar/image-bundle/composer.json
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "gregwar/image-bundle",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Image handling bundle",
|
||||
"keywords": ["symfony", "image"],
|
||||
"homepage": "https://github.com/Gregwar/ImageBundle",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Grégoire Passault",
|
||||
"email": "g.passault@gmail.com",
|
||||
"homepage": "http://www.gregwar.com/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"ext-gd": "*",
|
||||
"symfony/framework-bundle": "^2.3 || ^3.0 || ^4.0",
|
||||
"twig/twig": "^1.12 || ^2.0",
|
||||
"gregwar/image": "2.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"sllh/php-cs-fixer-styleci-bridge": "~1.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Gregwar\\ImageBundle\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue