diff --git a/.gitignore b/.gitignore index d6aab3ab9..6944c8f15 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ composer.lock composer.phar vendor/ -/Tests/Functional/app/web/media/cache +Tests/Functional/app/web/media/cache diff --git a/Imagine/Data/Loader/AbstractDoctrineLoader.php b/Binary/Loader/AbstractDoctrineLoader.php similarity index 97% rename from Imagine/Data/Loader/AbstractDoctrineLoader.php rename to Binary/Loader/AbstractDoctrineLoader.php index ad681dc16..f65189560 100644 --- a/Imagine/Data/Loader/AbstractDoctrineLoader.php +++ b/Binary/Loader/AbstractDoctrineLoader.php @@ -1,6 +1,6 @@ findTaggedServiceIds('liip_imagine.data.loader'); + $tags = $container->findTaggedServiceIds('liip_imagine.binary.loader'); if (count($tags) > 0 && $container->hasDefinition('liip_imagine.data.manager')) { $manager = $container->getDefinition('liip_imagine.data.manager'); diff --git a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php index 7468c3e11..43532c865 100644 --- a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php +++ b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php @@ -12,12 +12,12 @@ class FileSystemLoaderFactory implements LoaderFactoryInterface */ public function create(ContainerBuilder $container, $loaderName, array $config) { - $loaderDefinition = new DefinitionDecorator('liip_imagine.data.loader.prototype.filesystem'); + $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.filesystem'); $loaderDefinition->replaceArgument(2, $config['data_root']); - $loaderDefinition->addTag('liip_imagine.data.loader', array( + $loaderDefinition->addTag('liip_imagine.binary.loader', array( 'loader' => $loaderName )); - $loaderId = 'liip_imagine.data.loader.'.$loaderName; + $loaderId = 'liip_imagine.binary.loader.'.$loaderName; $container->setDefinition($loaderId, $loaderDefinition); diff --git a/DependencyInjection/Factory/Loader/StreamLoaderFactory.php b/DependencyInjection/Factory/Loader/StreamLoaderFactory.php index ba33fb115..46ce26c2b 100644 --- a/DependencyInjection/Factory/Loader/StreamLoaderFactory.php +++ b/DependencyInjection/Factory/Loader/StreamLoaderFactory.php @@ -12,13 +12,13 @@ class StreamLoaderFactory implements LoaderFactoryInterface */ public function create(ContainerBuilder $container, $loaderName, array $config) { - $loaderDefinition = new DefinitionDecorator('liip_imagine.data.loader.prototype.stream'); + $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.stream'); $loaderDefinition->replaceArgument(0, $config['wrapper']); $loaderDefinition->replaceArgument(1, $config['context']); - $loaderDefinition->addTag('liip_imagine.data.loader', array( + $loaderDefinition->addTag('liip_imagine.binary.loader', array( 'loader' => $loaderName )); - $loaderId = 'liip_imagine.data.loader.'.$loaderName; + $loaderId = 'liip_imagine.binary.loader.'.$loaderName; $container->setDefinition($loaderId, $loaderDefinition); diff --git a/DependencyInjection/LiipImagineExtension.php b/DependencyInjection/LiipImagineExtension.php index 82c9b61e7..20eb81e58 100644 --- a/DependencyInjection/LiipImagineExtension.php +++ b/DependencyInjection/LiipImagineExtension.php @@ -61,7 +61,7 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('liip_imagine.filter_sets', $config['filter_sets']); - $container->setParameter('liip_imagine.data.loader.default', $config['data_loader']); + $container->setParameter('liip_imagine.binary.loader.default', $config['data_loader']); $container->setParameter('liip_imagine.controller_action', $config['controller_action']); diff --git a/Imagine/Data/DataManager.php b/Imagine/Data/DataManager.php index c5cc0f8e6..6c90430df 100644 --- a/Imagine/Data/DataManager.php +++ b/Imagine/Data/DataManager.php @@ -2,7 +2,7 @@ namespace Liip\ImagineBundle\Imagine\Data; -use Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface; +use Liip\ImagineBundle\Binary\Loader\LoaderInterface; use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration; use Liip\ImagineBundle\Binary\MimeTypeGuesserInterface; use Liip\ImagineBundle\Model\Binary; diff --git a/Resources/config/imagine.xml b/Resources/config/imagine.xml index fa754fc9d..7edccc9bf 100644 --- a/Resources/config/imagine.xml +++ b/Resources/config/imagine.xml @@ -47,8 +47,8 @@ - Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader - Liip\ImagineBundle\Imagine\Data\Loader\StreamLoader + Liip\ImagineBundle\Binary\Loader\FileSystemLoader + Liip\ImagineBundle\Binary\Loader\StreamLoader @@ -76,7 +76,7 @@ - %liip_imagine.data.loader.default% + %liip_imagine.binary.loader.default% @@ -179,13 +179,13 @@ - + - + diff --git a/Resources/doc/data-loader/gridfs.md b/Resources/doc/data-loader/gridfs.md index 454c4478c..3f46adeb5 100644 --- a/Resources/doc/data-loader/gridfs.md +++ b/Resources/doc/data-loader/gridfs.md @@ -14,8 +14,8 @@ liip_imagine: Add loader to your services: ``` xml - - + + Application\ImageBundle\Document\Image diff --git a/Resources/doc/data-loader/stream.md b/Resources/doc/data-loader/stream.md index 935a41141..c77b1f0f4 100644 --- a/Resources/doc/data-loader/stream.md +++ b/Resources/doc/data-loader/stream.md @@ -12,7 +12,7 @@ liip_imagine: ## Custom -The `Liip\ImagineBundle\Imagine\Data\Loader\StreamLoader` allows to read images from any stream registered +The `Liip\ImagineBundle\Binary\Loader\StreamLoader` allows to read images from any stream registered thus allowing you to serve your images from literally anywhere. The example service definition shows how to use a stream wrapped by the [Gaufrette](https://github.com/KnpLabs/Gaufrette) filesystem abstraction layer. @@ -24,12 +24,12 @@ you can make use of the [StreamWrapper configuration](https://github.com/KnpLabs ``` yaml services: - acme.liip_imagine.data.loader.stream.profile_photos: - class: "%liip_imagine.data.loader.stream.class%" + acme.liip_imagine.binary.loader.stream.profile_photos: + class: "%liip_imagine.binary.loader.stream.class%" arguments: - 'gaufrette://profile_photos/' tags: - - { name: 'liip_imagine.data.loader', loader: 'stream.profile_photos' } + - { name: 'liip_imagine.binary.loader', loader: 'stream.profile_photos' } ``` ## Usage diff --git a/Resources/doc/data-loaders.md b/Resources/doc/data-loaders.md index f5e09cc16..048cf12a4 100644 --- a/Resources/doc/data-loaders.md +++ b/Resources/doc/data-loaders.md @@ -15,14 +15,14 @@ The ImagineBundle allows you to add your custom image loader classes. The only requirement is that each data loader implement the following interface: - Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface + Liip\ImagineBundle\Binary\Loader\LoaderInterface To tell the bundle about your new data loader, register it in the service -container and apply the `liip_imagine.data.loader` tag to it (example here in XML): +container and apply the `liip_imagine.binary.loader` tag to it (example here in XML): ``` xml - - + + ``` @@ -51,13 +51,13 @@ liip_imagine: For an example of a data loader implementation, refer to -`Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader`. +`Liip\ImagineBundle\Binary\Loader\FileSystemLoader`. ## Extending the image loader with data transformers You can extend a custom data loader to support virtually any file type using transformers. A data tranformer is intended to transform a file before actually rendering it. You -can refer to `Liip\ImagineBundle\Imagine\Data\Loader\ExtendedFileSystemLoader` and +can refer to `Liip\ImagineBundle\Binary\Loader\ExtendedFileSystemLoader` and to `Liip\ImagineBundle\Imagine\Data\Transformer\PdfTransformer` as an example. ExtendedFileSystemLoader extends FileSystemLoader and takes, as argument, an array of transformers. @@ -79,7 +79,7 @@ services: custom_loader: class: Acme\ImagineBundle\Imagine\Data\Loader\MyCustomDataLoader tags: - - { name: liip_imagine.data.loader, loader: custom_data_loader } + - { name: liip_imagine.binary.loader, loader: custom_data_loader } arguments: - '@liip_imagine' - %kernel.root_dir%/../web diff --git a/Resources/doc/introduction.md b/Resources/doc/introduction.md index 7737e3eb6..95d0d4cff 100644 --- a/Resources/doc/introduction.md +++ b/Resources/doc/introduction.md @@ -9,10 +9,10 @@ There are several components involved to get this done. The first step is to retrieve the original image, the one you address. -In order to retrieve such an image, there are so-called `DataLoader` those implement the `Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface`. +In order to retrieve such an image, there are so-called `DataLoader` those implement the `Liip\ImagineBundle\Binary\Loader\LoaderInterface`. Those loaders are typically managed by the `DataManager` and automatically wired with it, using dependency injection. -How a specific `DataLoader` retrieves the image, is up to the loader. The most simple way is to read a file from the local filesystem. This is implemented by the `Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader`, which is set by default. +How a specific `DataLoader` retrieves the image, is up to the loader. The most simple way is to read a file from the local filesystem. This is implemented by the `Liip\ImagineBundle\Binary\Loader\FileSystemLoader`, which is set by default. You could also create a random image on the fly using drawing utilities, or read a binary stream from any stream registered. The most important parts about those `DataLoader`: diff --git a/Tests/Imagine/Data/Loader/FileSystemLoaderTest.php b/Tests/Binary/Loader/FileSystemLoaderTest.php similarity index 87% rename from Tests/Imagine/Data/Loader/FileSystemLoaderTest.php rename to Tests/Binary/Loader/FileSystemLoaderTest.php index 0b296d0e3..087374f10 100644 --- a/Tests/Imagine/Data/Loader/FileSystemLoaderTest.php +++ b/Tests/Binary/Loader/FileSystemLoaderTest.php @@ -1,8 +1,8 @@ assertTrue($rc->implementsInterface('Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface')); + $this->assertTrue($rc->implementsInterface('Liip\ImagineBundle\Binary\Loader\LoaderInterface')); } public function testCouldBeConstructedWithExpectedArguments() diff --git a/Tests/Imagine/Data/Loader/StreamLoaderTest.php b/Tests/Binary/Loader/StreamLoaderTest.php similarity index 88% rename from Tests/Imagine/Data/Loader/StreamLoaderTest.php rename to Tests/Binary/Loader/StreamLoaderTest.php index 99188d0a4..09e640198 100644 --- a/Tests/Imagine/Data/Loader/StreamLoaderTest.php +++ b/Tests/Binary/Loader/StreamLoaderTest.php @@ -1,12 +1,12 @@ 'theDataRoot', )); - $this->assertTrue($container->hasDefinition('liip_imagine.data.loader.theloadername')); + $this->assertTrue($container->hasDefinition('liip_imagine.binary.loader.theloadername')); - $loaderDefinition = $container->getDefinition('liip_imagine.data.loader.theloadername'); + $loaderDefinition = $container->getDefinition('liip_imagine.binary.loader.theloadername'); $this->assertInstanceOf('Symfony\Component\DependencyInjection\DefinitionDecorator', $loaderDefinition); - $this->assertEquals('liip_imagine.data.loader.prototype.filesystem', $loaderDefinition->getParent()); + $this->assertEquals('liip_imagine.binary.loader.prototype.filesystem', $loaderDefinition->getParent()); $this->assertEquals('theDataRoot', $loaderDefinition->getArgument(2)); } diff --git a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php index bcebcc7ed..fb01f8368 100644 --- a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php @@ -38,11 +38,11 @@ public function testCreateLoaderDefinitionOnCreate() 'context' => 'theContext', )); - $this->assertTrue($container->hasDefinition('liip_imagine.data.loader.theloadername')); + $this->assertTrue($container->hasDefinition('liip_imagine.binary.loader.theloadername')); - $loaderDefinition = $container->getDefinition('liip_imagine.data.loader.theloadername'); + $loaderDefinition = $container->getDefinition('liip_imagine.binary.loader.theloadername'); $this->assertInstanceOf('Symfony\Component\DependencyInjection\DefinitionDecorator', $loaderDefinition); - $this->assertEquals('liip_imagine.data.loader.prototype.stream', $loaderDefinition->getParent()); + $this->assertEquals('liip_imagine.binary.loader.prototype.stream', $loaderDefinition->getParent()); $this->assertEquals('theWrapper', $loaderDefinition->getArgument(0)); $this->assertEquals('theContext', $loaderDefinition->getArgument(1)); diff --git a/Tests/Functional/app/web/media/cache/thumbnail_web_path/S8rrlhhQ/images/cats.jpeg b/Tests/Functional/app/web/media/cache/thumbnail_web_path/S8rrlhhQ/images/cats.jpeg deleted file mode 100644 index 898671066..000000000 Binary files a/Tests/Functional/app/web/media/cache/thumbnail_web_path/S8rrlhhQ/images/cats.jpeg and /dev/null differ diff --git a/Tests/Imagine/Data/DataManagerTest.php b/Tests/Imagine/Data/DataManagerTest.php index 8e880420d..2ea20b47a 100644 --- a/Tests/Imagine/Data/DataManagerTest.php +++ b/Tests/Imagine/Data/DataManagerTest.php @@ -3,7 +3,7 @@ namespace Liip\ImagineBundle\Tests\Imagine\Data; use Liip\ImagineBundle\Imagine\Data\DataManager; -use Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface; +use Liip\ImagineBundle\Binary\Loader\LoaderInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; @@ -340,7 +340,7 @@ public function testShouldReturnBinaryWithLoaderContentAndGuessedFormatOnFind() */ protected function getMockLoader() { - return $this->getMock('Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface'); + return $this->getMock('Liip\ImagineBundle\Binary\Loader\LoaderInterface'); } /** diff --git a/UPGRADE.md b/UPGRADE.md index 61f009fed..50142af43 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -28,6 +28,12 @@ Upgrade * [Cache] `AbstractFilesystemResolver` was removed. * [Data] `LoaderInterface::find` now can return string or `BinaryInterface` instance. * [Data] `DataManager::find` now can return `BinaryInterface` instance only. +* [Data] All data loaders moved to `Binary/Loader` folder. +* [Data] Tag name `liip_imagine.data.loader` changed to `liip_imagine.binary.loader` +* [Data] Parameter key `liip_imagine.data.loader.filesystem.class` changed to `liip_imagine.binary.loader.filesystem.class` +* [Data] Parameter key `liip_imagine.data.loader.stream.class` changed to `liip_imagine.binary.loader.stream.class` +* [Data] Service id `liip_imagine.data.loader.prototype.filesystem` changed to `liip_imagine.binary.loader.prototype.filesystem` +* [Data] Service id `liip_imagine.data.loader.prototype.stream` changed to `liip_imagine.binary.loader.prototype.stream` * [Filter] `FilterManager::applyFilter` now return instance of `BinaryInterface`. * [Filter] `FilterManager::applyFilter` first argument was changed from Image instance to BinaryInterface one. * [Filter] `FilterManager::get` was removed.