Skip to content

Commit

Permalink
Expose Autoload internal data (so it can used by 3rd parties projects)
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Jun 20, 2015
1 parent 977fe9f commit 4a07e6c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/Autoloader/Generator.php
Expand Up @@ -61,6 +61,8 @@ class Generator
protected $hasTraits;
protected $hasInterface;

protected $parsed = false;

/** settings */

protected $relative = false;
Expand Down Expand Up @@ -91,18 +93,24 @@ public function multipleFiles()

public function includeFiles(Array $files)
{
/** reset all parser data */
$this->parsed = false;
$this->includes = array_merge($this->includes, $files);
return $this;
}

public function relativePaths ($rel = true)
{
/** reset all parser data */
$this->parsed = false;
$this->relative = $rel;
return $this;
}

public function IncludePSR0Autoloader($psr0 = true)
{
/** reset all parser data */
$this->parserd = false;
$this->include_psr0 = $psr0;
return $this;
}
Expand All @@ -123,6 +131,9 @@ protected function checkDirExists($dir)
}

public function setScanPath($dir) {
/** reset all parser data */
$this->parsed = false;

if ($dir instanceof Finder || is_array($dir)) {
$this->path = $dir;
return true;
Expand Down Expand Up @@ -414,7 +425,7 @@ protected function saveCache($cache, $zfiles, $files, $cached)
*
* @return []
*/
public function getPHPFiles($zfiles)
public function getPHPFiles(&$zfiles)
{
$files = array();
foreach ($this->path as $file) {
Expand All @@ -423,7 +434,7 @@ public function getPHPFiles($zfiles)
continue;
}

$files[$path] = filemtime($path);
$zfiles[$path] = filemtime($path);
if (!preg_match('/\s(class|interface|trait)\s/ismU', file_get_contents($path))) {
/* no classes */
continue;
Expand All @@ -433,8 +444,12 @@ public function getPHPFiles($zfiles)
return $files;
}

public function generate($output, $cache = '')
public function parse($output, $cache = NULL)
{
if (!empty($this->parsed)) {
return $this->getTemplateArgs();;
}

$dir = realpath(dirname($output));
$this->checkDirExists($dir);

Expand Down Expand Up @@ -469,6 +484,12 @@ public function generate($output, $cache = '')
$this->loadClassesFromCache($cached);
$this->saveCache($cache, $zfiles, $files, $cached);
$this->generateClassDependencyTree();
return $this->getTemplateArgs();
}

public function generate($output, $cache = '')
{
$this->parse($output, $cache);
$this->writeAutoloader($output);
}

Expand Down

0 comments on commit 4a07e6c

Please sign in to comment.