protected function requireTree($tree) { $rootDir = $this->file->full_dir(); $path = $rootDir . '/' . $tree; $realPath = realpath($path); if (!$realPath) { throw new Exception\RuntimeException(sprintf("Path to tree not found: %s", $path)); } # Require files in root directory. $this->requireDir($tree); # Require files in sub directories. $allDirs = Toolbox\FileTools::listDirs($realPath); foreach ($allDirs as $dir) { $relativeDir = trim(substr($dir, strlen($rootDir)), '/'); $this->requireDir($relativeDir); } }
private function runInitializers() { $dirName = 'initializers'; $path = $this->config()->paths->config->concat($dirName); if (is_dir($path)) { $files = []; $patt = $path . '/*.php'; $files = array_merge($files, glob($patt) ?: []); foreach (Toolbox\FileTools::listDirs($path) as $dir) { $patt = $dir . '/*.php'; $files = array_merge($files, glob($patt) ?: []); } foreach ($files as $file) { require $file; } } }