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

Removed webRoot logic outside controller #28

Merged
merged 4 commits into from
Oct 31, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 1 addition & 10 deletions Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ class ImagineController
*/
private $filterManager;

/**
* @var string
*/
private $webRoot;

/**
* @var CachePathResolver
*/
Expand All @@ -35,14 +30,12 @@ class ImagineController
*
* @param LoaderInterface $dataLoader
* @param FilterManager $filterManager
* @param string $webRoot
* @param CachePathResolver $cachePathResolver
*/
public function __construct(LoaderInterface $dataLoader, FilterManager $filterManager, $webRoot, CachePathResolver $cachePathResolver = null)
public function __construct(LoaderInterface $dataLoader, FilterManager $filterManager, CachePathResolver $cachePathResolver = null)
{
$this->dataLoader = $dataLoader;
$this->filterManager = $filterManager;
$this->webRoot = realpath($webRoot);
$this->cachePathResolver = $cachePathResolver;
}

Expand All @@ -59,8 +52,6 @@ public function __construct(LoaderInterface $dataLoader, FilterManager $filterMa
*/
public function filterAction(Request $request, $path, $filter)
{
$path = $this->webRoot.'/'.ltrim($path, '/');

$targetPath = false;
if ($this->cachePathResolver) {
$targetPath = $this->cachePathResolver->resolve($request, $path, $filter);
Expand Down
4 changes: 0 additions & 4 deletions Imagine/CachePathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public function __construct(RouterInterface $router, Filesystem $filesystem, $we
*/
public function getBrowserPath($targetPath, $filter, $absolute = false)
{
if (0 === strpos($targetPath, $this->webRoot)) {
$targetPath = substr($targetPath, strlen($this->webRoot));
}

$params = array('path' => ltrim($targetPath, '/'));

$path = str_replace(
Expand Down
11 changes: 10 additions & 1 deletion Imagine/DataLoader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ class FileSystemLoader implements LoaderInterface
*/
private $formats;

/**
* @var string
*/
private $webRoot;

/**
* Constructs
*
* @param ImagineInterface $imagine
* @param array $formats
* @param string $webRoot
*/
public function __construct(ImagineInterface $imagine, $formats)
public function __construct(ImagineInterface $imagine, $formats, $webRoot)
{
$this->imagine = $imagine;
$this->formats = $formats;
$this->webRoot = realpath($webRoot);
}

/**
Expand All @@ -37,6 +44,8 @@ public function __construct(ImagineInterface $imagine, $formats)
*/
public function find($path)
{
$path = $this->webRoot.'/'.ltrim($path, '/');;

$info = pathinfo($path);

$name = $info['dirname'].'/'.$info['filename'];
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/imagine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
<service id="liip_imagine.loader.filesystem" class="%liip_imagine.loader.filesystem.class%">
<argument type="service" id="imagine" />
<argument>%liip_imagine.formats%</argument>
<argument>%liip_imagine.web_root%</argument>
</service>

<!-- Controller -->

<service id="liip_imagine.controller" class="%liip_imagine.controller.class%">
<argument type="service" id="liip_imagine.loader.filesystem" />
<argument type="service" id="liip_imagine.filter.manager" />
<argument>%liip_imagine.web_root%</argument>
</service>

<!-- Route Loader -->
Expand Down