Merge pull request #162 from ericclemmons/patch-1
ProxyFactory creates proxy's parent structure if it doesn't exist
This commit is contained in:
commit
6b1ef08a46
@ -36,6 +36,10 @@ class ProxyException extends \Doctrine\ORM\ORMException {
|
|||||||
return new self("You must configure a proxy directory. See docs for details");
|
return new self("You must configure a proxy directory. See docs for details");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function proxyDirectoryNotWritable() {
|
||||||
|
return new self("Your proxy directory must be writable.");
|
||||||
|
}
|
||||||
|
|
||||||
public static function proxyNamespaceRequired() {
|
public static function proxyNamespaceRequired() {
|
||||||
return new self("You must configure a proxy namespace. See docs for details");
|
return new self("You must configure a proxy namespace. See docs for details");
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,16 @@ class ProxyFactory
|
|||||||
|
|
||||||
$file = str_replace($placeholders, $replacements, $file);
|
$file = str_replace($placeholders, $replacements, $file);
|
||||||
|
|
||||||
|
$parentDirectory = dirname($fileName);
|
||||||
|
|
||||||
|
if ( ! is_dir($parentDirectory)) {
|
||||||
|
if (false === @mkdir($parentDirectory, 0775, true)) {
|
||||||
|
throw ProxyException::proxyDirectoryNotWritable();
|
||||||
|
}
|
||||||
|
} else if ( ! is_writable($parentDirectory)) {
|
||||||
|
throw ProxyException::proxyDirectoryNotWritable();
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($fileName, $file, LOCK_EX);
|
file_put_contents($fileName, $file, LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user