Skip to content

Commit

Permalink
Merge pull request #112 from kevarch/master
Browse files Browse the repository at this point in the history
Adding cache directory permissions configuration parameter
  • Loading branch information
lsmith77 committed Oct 24, 2012
2 parents 922535f + a443e6e commit 1e41b3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public function process(ContainerBuilder $container)
$webRoot = $container->getParameter('liip_imagine.web_root');
$cachePrefix = $container->getParameter('liip_imagine.cache_prefix');
$filters = $container->getParameter('liip_imagine.filters');
$mode = $container->getParameter('liip_imagine.cache_mkdir_mode');

foreach ($filters as $filter => $options) {
$dir = isset($options['path'])
? $webRoot.$options['path']
: $webRoot.$cachePrefix.'/'.$filter;

if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
if (!is_dir($dir) && !mkdir($dir, $mode, true)) {
throw new \RuntimeException(sprintf(
'Could not create directory for caching processed '.
'images in "%s"', $dir
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getConfigTreeBuilder()
->end()
->scalarNode('web_root')->defaultValue('%kernel.root_dir%/../web')->end()
->scalarNode('data_root')->defaultValue('%liip_imagine.web_root%')->end()
->scalarNode('cache_mkdir_mode')->defaultValue(0777)->end()
->scalarNode('cache_prefix')->defaultValue('/media/cache')->end()
->scalarNode('cache')->defaultValue('web_path')->end()
->scalarNode('cache_base_path')->defaultValue('')->end()
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ liip_imagine:
driver: gd
web_root: %kernel.root_dir%/../web
data_root: %liip_imagine.web_root%
cache_mkdir_mode: 0777
cache_prefix: /media/cache
cache: web_path
cache_clearer: true
Expand Down Expand Up @@ -203,6 +204,12 @@ There are several configuration options available:

default: `%kernel.root_dir%/../web`

- `cache_mkdir_mode` - permissions to set on generated cache directories.
Must be specified as an octal number, which means it should begin with a
leading zero. mode is ignored on Windows.

default: `0777`

- `cache_prefix` - this is also used in the path for image generation, so
as to not clutter your web root with cached images. For example by default,
the images would be written to the `web/media/cache/` directory.
Expand Down

0 comments on commit 1e41b3c

Please sign in to comment.