Skip to content

Commit

Permalink
Merge pull request #26 from Vincz/master
Browse files Browse the repository at this point in the history
Make created cache dir mask as option and default to 0777
  • Loading branch information
mcg-web committed Jan 13, 2019
2 parents acea33b + 42f7763 commit 6a131a9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Generator/AbstractTypeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ function (%s) <closureUseStatements>{
*/
private $expressionLanguage;

/**
* @var int
*/
protected $cacheDirMask;

/**
* @param string $classNamespace The namespace to use for the classes.
* @param string[]|string $skeletonDirs
*/
public function __construct($classNamespace = self::DEFAULT_CLASS_NAMESPACE, $skeletonDirs = [])
public function __construct($classNamespace = self::DEFAULT_CLASS_NAMESPACE, $skeletonDirs = [], $cacheDirMask = 0775)
{
parent::__construct($classNamespace, $skeletonDirs);
$this->cacheDirMask = $cacheDirMask;
}

public function setExpressionLanguage(ExpressionLanguage $expressionLanguage = null)
Expand Down Expand Up @@ -361,7 +367,7 @@ public function generateClass(array $config, $outputDirectory, $mode = false)
if ($mode & self::MODE_WRITE) {
$dir = dirname($path);
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
mkdir($dir, $this->cacheDirMask, true);
}
if (($mode & self::MODE_OVERRIDE) || !file_exists($path)) {
file_put_contents($path, $code);
Expand Down

0 comments on commit 6a131a9

Please sign in to comment.