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

Move data loaders to binary folder #382

Merged
merged 4 commits into from
Apr 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

use Imagine\Image\ImagineInterface;
use Liip\ImagineBundle\Imagine\Data\Transformer\TransformerInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

use Liip\ImagineBundle\Model\Binary;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

use Doctrine\ODM\MongoDB\DocumentManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

interface LoaderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liip\ImagineBundle\Imagine\Data\Loader;
namespace Liip\ImagineBundle\Binary\Loader;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Data/DataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/imagine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

<!-- Data loaders' classes -->

<parameter key="liip_imagine.data.loader.filesystem.class">Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader</parameter>
<parameter key="liip_imagine.data.loader.stream.class">Liip\ImagineBundle\Imagine\Data\Loader\StreamLoader</parameter>
<parameter key="liip_imagine.data.loader.filesystem.class">Liip\ImagineBundle\Binary\Loader\FileSystemLoader</parameter>
<parameter key="liip_imagine.data.loader.stream.class">Liip\ImagineBundle\Binary\Loader\StreamLoader</parameter>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liip_imagine.data.loader.xxx.class -> liip_imagine.binary.loader.xxx.class


<!-- Cache resolvers' classes -->

Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/data-loader/gridfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ liip_imagine:
Add loader to your services:

``` xml
<service id="liip_imagine.data.loader.grid_fs" class="Liip\ImagineBundle\Imagine\Data\Loader\GridFSLoader">
<service id="liip_imagine.data.loader.grid_fs" class="Liip\ImagineBundle\Binary\Loader\GridFSLoader">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

liip_imagine.data.loader.grid_fs -> liip_imagine.binary.loader.grid_fs

same for others.

<tag name="liip_imagine.data.loader" loader="grid_fs" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag name has also be renamed, dont forget to mention it in the UPGRADE.md

<argument type="service" id="liip_imagine" />
<argument type="service" id="doctrine.odm.mongodb.document_manager" />
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/data-loader/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions Resources/doc/data-loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
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):

``` xml
<service id="acme_imagine.data.loader.my_custom" class="Acme\ImagineBundle\Imagine\Data\Loader\MyCustomDataLoader">
<service id="acme_imagine.data.loader.my_custom" class="Acme\ImagineBundle\Binary\Loader\MyCustomDataLoader">
<tag name="liip_imagine.data.loader" loader="my_custom_data" />
<argument type="service" id="liip_imagine" />
</service>
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Resources/doc/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Tests/Imagine/Data/DataManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Tests/Imagine/Data/Loader/FileSystemLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Liip\ImagineBundle\Tests\Imagine\Data\Loader;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move tests to Liip\ImagineBundle\Tests\Binary\Loader;


use Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader;
use Liip\ImagineBundle\Binary\Loader\FileSystemLoader;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface;
Expand All @@ -27,9 +27,9 @@ public static function provideLoadCases()

public function testShouldImplementLoaderInterface()
{
$rc = new \ReflectionClass('Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader');
$rc = new \ReflectionClass('Liip\ImagineBundle\Binary\Loader\FileSystemLoader');

$this->assertTrue($rc->implementsInterface('Liip\ImagineBundle\Imagine\Data\Loader\LoaderInterface'));
$this->assertTrue($rc->implementsInterface('Liip\ImagineBundle\Binary\Loader\LoaderInterface'));
}

public function testCouldBeConstructedWithExpectedArguments()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Imagine/Data/Loader/StreamLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Liip\ImagineBundle\Tests\Imagine\Data\Loader;

use Liip\ImagineBundle\Imagine\Data\Loader\StreamLoader;
use Liip\ImagineBundle\Binary\Loader\StreamLoader;
use Liip\ImagineBundle\Tests\AbstractTest;

/**
* @covers Liip\ImagineBundle\Imagine\Data\Loader\StreamLoader
* @covers Liip\ImagineBundle\Binary\Loader\StreamLoader
*/
class StreamLoaderTest extends AbstractTest
{
Expand Down