Browse Source

Merge remote-tracking branch 'origin/extended_classes' into sql_criteria

namespace
Alexander Demidov 11 years ago
parent
commit
d019ae2450
  1. 1
      Load.php
  2. 18
      util/AsciiSortedIterator.php
  3. 6
      util/AutoloadBuilder.php

1
Load.php

@ -79,6 +79,7 @@ class Load
if (!self::$builder) {
require_once(PATH . '/lib/core/util/AutoloadBuilder.php');
require_once(PATH . '/lib/core/util/AsciiSortedIterator.php');
self::$builder = new AutoloadBuilder(self::$file, $scan, $exclude);
}
self::$builder->build();

18
util/AsciiSortedIterator.php

@ -0,0 +1,18 @@
<?php
class AsciiSortedIterator extends SplHeap
{
public function __construct(Iterator $iterator)
{
foreach ($iterator as $item) {
$this->insert($item);
}
}
public function compare($b,$a)
{
/**
* @var $a SplFileInfo
* @var $b SplFileInfo
*/
return strcmp($a->getPath() . DIRECTORY_SEPARATOR . $a->getFileName(), $b->getPath() . DIRECTORY_SEPARATOR . $b->getFileName());
}
}

6
util/AutoloadBuilder.php

@ -38,10 +38,10 @@ class AutoloadBuilder
$classes = array();
foreach ($this->dirs as $dir) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir),
new RecursiveDirectoryIterator($dir, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::LEAVES_ONLY
);
$iterator = new AsciiSortedIterator($iterator);
foreach ($iterator as $file) {
/**
* @var SplFileInfo $file
@ -58,7 +58,7 @@ class AutoloadBuilder
$content = file_get_contents($file->getRealPath());
$matches = array();
$relative_path = substr($file->getRealPath(), strlen(PATH));
$relative_path = substr($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename(), strlen(PATH));
if (preg_match_all($this->regex, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {

Loading…
Cancel
Save