Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update Imagine/CacheManager.php #124

Closed
wants to merge 1 commit into from

2 participants

CachoRios Bulat Shakirzyanov
CachoRios

is_dir no funcioan bien, el bug esta en el manual online de php, y proponen esa funcion que puse.

CachoRios cachorios Update Imagine/CacheManager.php
is_dir no funcioan bien, el bug esta en el manual online de php, y proponen esa funcion que puse.
1099305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2013
  1. CachoRios

    Update Imagine/CacheManager.php

    cachorios authored
    is_dir no funcioan bien, el bug esta en el manual online de php, y proponen esa funcion que puse.
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 2 deletions.
  1. +26 −2 Imagine/CacheManager.php
28 Imagine/CacheManager.php
View
@@ -49,6 +49,8 @@ public function cacheImage($basePath, $path, $filter)
{
$path = '/'.ltrim($path, '/');
+
+
//TODO: find out why I need double urldecode to get a valid path
$browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter)));
@@ -56,6 +58,7 @@ public function cacheImage($basePath, $path, $filter)
$browserPath = substr($browserPath, strlen($basePath));
}
+
// if cache path cannot be determined, return 404
if (null === $browserPath) {
return null;
@@ -64,26 +67,37 @@ public function cacheImage($basePath, $path, $filter)
$realPath = $this->webRoot.$browserPath;
$sourcePath = $this->sourceRoot.$path;
+
+
// if the file has already been cached, just return path
if (file_exists($realPath)) {
return $realPath;
}
- if (!file_exists($sourcePath)) {
+
+ if (!file_exists($sourcePath)) {
return null;
}
+
$dir = pathinfo($realPath, PATHINFO_DIRNAME);
- if (!is_dir($dir)) {
+
+
+ if (!$this->is_dir($dir)) {
+
if (false === $this->filesystem->mkdir($dir)) {
+
throw new \RuntimeException(sprintf(
'Could not create directory %s', $dir
));
}
+
}
// TODO: get rid of hard-coded quality and format
+
+
$this->filterManager->getFilter($filter)
->apply($this->imagine->open($sourcePath))
->save($realPath, array(
@@ -94,4 +108,14 @@ public function cacheImage($basePath, $path, $filter)
return $realPath;
}
+
+ /**
+ * en reemplazo de is_dir que no funciona bien
+ * @param $path
+ *
+ * @return bool
+ */
+ function is_dir($path){
+ return (('d'==substr(exec("ls -dl '$path'"),0,1))?(true):(false));
+ }
}
Something went wrong with that request. Please try again.