示例#1
0
 /**
  * Основной метод, получающий абсолютный путь к классу.
  * 
  * @param str $class
  * @return str - Путь к файлу
  */
 private function getClassPathImpl($class)
 {
     /* @var $classPathDir AutoloadDir */
     foreach ($this->DIRS as $classPathDir) {
         //ИЩЕМ КЛАСС
         $path = $classPathDir->getClassPath($class);
         if ($path) {
             /*
              * Мы нашли класс!
              * Если он отмечен, как исключённый для всех - сборосим список исключённых.
              * Могло так случиться, что класс загружался без подключённой директорией (например admin).
              */
             if ($this->isCommonExcluded($class)) {
                 $this->LOGGER->info("Class [{$class}] was marked as excluded, but now found in {$classPathDir}. Clearing excluded.");
                 $this->cleanCommonExcluded();
             }
             return $path;
         }
     }
     //ПОПРОБУЕМ ВОСПОЛЬЗОВАТЬСЯ ФОЛДИНГАМИ
     $path = Handlers::tryGetFoldedEntityClassPath($class);
     if ($path) {
         $this->LOGGER->info("Class path for [{$class}] found with folded resources.");
         return $path;
     }
     //МЫ НЕ НАШЛИ НАШ КЛАСС В ПУТЯХ, А МОЖЕТ ОН ИСКЛЮЧЁН ДЛЯ ВСЕХ?
     if ($this->isCommonExcluded($class)) {
         $this->LOGGER->info("Class [{$class}] is common excluded.");
         return null;
     }
     //КЛАСС НЕ ЯВЛЯЕТСЯ КЛАССОМ СУЩНОСТИ ФОЛДИНГА. ПЕРЕСТРОИМ КЛАССПАСЫ ДЛЯ ЗАКЕШОРОВАННЫХ ДИРЕКТОРИЙ ИЛИ ОТМЕТИМ КЛАСС, КАК ИСКЛЮЧЁННЫЙ
     /* @var $classPathDir AutoloadDir */
     foreach ($this->DIRS as $classPathDir) {
         if ($classPathDir->isRebuilded()) {
             //Данную директорию уже перезагружали, в ней класса точно нет
             continue;
         }
         //Если файл не найден, но при этом класспас не перестраивался, то необходимо поискать его заново
         $this->LOGGER->info("Class [{$class}] not excluded, need to check {$classPathDir} again.");
         $path = $classPathDir->rebuild()->getClassPath($class);
         if ($path) {
             //Ура, наши класс в одной из директорий
             $this->LOGGER->info("Class [{$class}] found for {$classPathDir} after rebuild.");
             return $path;
         }
     }
     $this->saveCommonExcluded($class);
     $this->LOGGER->info("Class [{$class}] is marked as excluded, null is returned.");
     return null;
 }