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

Major Refactoring #25

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5cd209f
add / to cache prefix start to prevent duplicate // in case the cache…
lsmith77 Jul 21, 2011
4b47493
renamed filter() to filterAction()
lsmith77 Jul 21, 2011
9ad85ed
added ability to resolve the real path to the cache path resolver
lsmith77 Jul 21, 2011
06b00bb
refactored the controller
lsmith77 Jul 21, 2011
e21973a
properly set status code depending on if caching is active or not
lsmith77 Jul 21, 2011
7dff516
added support for 'json' format
lsmith77 Jul 21, 2011
9e0acb4
make the FileSytemLoader extensible
lsmith77 Jul 21, 2011
c051308
fixed content type for jpg
lsmith77 Jul 21, 2011
8608b6c
fixed handling of quality
lsmith77 Jul 21, 2011
a0a398a
add support for defining a filter without a type to return the origin…
lsmith77 Jul 22, 2011
0c7fd4a
typo fix
lsmith77 Jul 22, 2011
70e3415
make it possible to omit either the width or the heigth
lsmith77 Jul 22, 2011
5420858
make the Request instance a parameter to the resolve() method so that…
lsmith77 Jul 22, 2011
1dfffe3
assume that an unknown format is simply part of the name
lsmith77 Jul 26, 2011
5c1ba0d
allow a filter to be an empty string
lsmith77 Jul 26, 2011
939151c
minor cleanups to the json handling
lsmith77 Jul 26, 2011
9482895
added support for XML output
lsmith77 Jul 27, 2011
6b58fd0
Merge remote branch 'origin/master' into refactoring
lsmith77 Jul 29, 2011
c0f4c6f
cosmetics
lsmith77 Jul 31, 2011
21826a8
removed support for json/xml
lsmith77 Jul 31, 2011
0328bfb
removed outdated documentation
lsmith77 Jul 31, 2011
de3554c
accept request as an action parameter
lsmith77 Aug 4, 2011
2f941a8
filter loader already apply filter, by default do not upscale thumbnails
lsmith77 Aug 12, 2011
c8dda4c
moved quality to the main filter definition
lsmith77 Sep 11, 2011
366b914
added Configuration class for better validation
lsmith77 Sep 11, 2011
90b505c
tweaked options handling
lsmith77 Sep 11, 2011
460bddc
fixed driver validation
lsmith77 Sep 11, 2011
a0527b2
xml fix for options
lsmith77 Sep 11, 2011
274341c
added support for 'loader' config
lsmith77 Sep 11, 2011
ca2b88a
Added some tests for the DI extension
stof Sep 11, 2011
c72dab9
Added gmagick as valid driver
stof Sep 11, 2011
bbef47d
Merge pull request #1 from stof/liip-refactoring
lsmith77 Sep 11, 2011
9687337
typo fix
lsmith77 Sep 24, 2011
38ec845
handle path normaliztion inside the extension
lsmith77 Sep 25, 2011
b3ac477
fixed handling of options
lsmith77 Sep 26, 2011
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
Prev Previous commit
Next Next commit
added support for XML output
  • Loading branch information
lsmith77 committed Jul 27, 2011
commit 948289582a2ccd104775e0c2579fd47de9cb6dd1
44 changes: 28 additions & 16 deletions Controller/ImagineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,37 @@ public function filterAction($path, $filter)
));
}

if ('json' === $format) {
return new Response(json_encode($image), 200, array('Content-Type' => 'application/json'));
}
switch ($format) {
case 'json':
$response = new Response(json_encode($image), 200, array('Content-Type' => 'application/json'));
break;
case 'xml':
$xml = new \SimpleXMLElement('<response/>');
foreach ($image as $key => $value) {
$xml->addChild($key, $value);
}
$response = new Response($xml->asXML(), 200, array('Content-Type' => 'application/xml'));
break;
default:
$realPath = null;
if ($this->cachePathResolver) {
$realPath = $this->cachePathResolver->resolve($this->request, $path, $filter);
if (!$realPath) {
throw new NotFoundHttpException('Image doesn\'t exist');
}

$realPath = null;
if ($this->cachePathResolver) {
$realPath = $this->cachePathResolver->resolve($this->request, $path, $filter);
if (!$realPath) {
throw new NotFoundHttpException('Image doesn\'t exist');
}
if ($realPath instanceof Response) {
return $realPath;
}
}

if ($realPath instanceof Response) {
return $realPath;
}
$image = $this->filterManager->get($filter, $image, $realPath, $format);
$statusCode = $this->cachePathResolver ? 201 : 200;
$contentType = 'image/'.($format == 'jpg' ? 'jpeg' : $format);
$response = new Response($image, $statusCode, array('Content-Type' => $contentType));
break;
}

$image = $this->filterManager->get($filter, $image, $realPath, $format);
$statusCode = $this->cachePathResolver ? 201 : 200;
$contentType = 'image/'.($format == 'jpg' ? 'jpeg' : $format);
return new Response($image, $statusCode, array('Content-Type' => $contentType));
return $response;
}
}
2 changes: 1 addition & 1 deletion Imagine/DataLoader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function find($path)
}
}

if ('json' === $targetFormat) {
if ('json' === $targetFormat || 'xml' === $targetFormat) {
// TODO add more meta data about the image
$image = array('format' => $targetFormat);
} else {
Expand Down