/** * Loads a yaml configuration and adds it to stack * * @param string $uProjectConfigPath The path of yaml configuration file * * @return void * * @todo use cached reader and cache yaml */ public function addConfig($uPath) { if ($this->yamlParser === null) { $this->yamlParser = new Parser(); } $tYaml = $this->yamlParser->parse(FileSystem::read($uPath)); $this->config->add($tYaml); }
/** * Scans a file * * @param string $uFile file path * * @return void */ public function processFile($uFile) { $tFileContents = FileSystem::read($uFile); foreach ($this->scanners as $tScanner) { $tScanner->processFile($uFile, $tFileContents); } $tTokenStream = TokenStream::fromString($tFileContents); $this->processTokenStream($tTokenStream); }
/** * Compiles given configuration files into single configuration * * @return array final configuration */ public function get() { // TODO mass caching with pathnames and flags foreach ($this->paths as $tPath) { $tConfigPath = Core::$instance->translateVariables($tPath[0]); $tConfigContent = Core::$instance->cachedRead("file." . realpath($tConfigPath), function () use($tConfigPath) { $tParser = new Parser(); return $tParser->parse(FileSystem::read($tConfigPath)); }, ["ttl" => 60 * 60]); $this->process($this->content, $tConfigContent, $tPath[1]); } return $this->content; }
/** * Scans given file to search for classes * * @param string $uFile file * @param string $uNamespacePrefix namespace prefix * * @return void */ public function scanFile($uFile, $uNamespacePrefix) { $tFileContents = FileSystem::read($uFile); $tTokenStream = TokenStream::fromString($tFileContents); $this->annotationScanner->process($tTokenStream, $uNamespacePrefix); }
/** * Compiles given configuration files into single configuration * * @param null|string $uMimeTypeFilter only compiles filtered mimetypes * * @return void */ public function compile($uMimeTypeFilter = null) { if (count($this->contents) > 0) { $this->output = ""; foreach ($this->contents as $tContent) { if ($uMimeTypeFilter !== null && $uMimeTypeFilter !== $tContent[1]) { continue; } if ($tContent[0] === "direct") { $tOutput = $tContent[2]; } elseif ($tContent[0] === "callback") { $tOutput = call_user_func($tContent[2]); } elseif ($tContent[0] === "file") { $tOutput = FileSystem::read($tContent[2]); } if (isset($this->filters[$tContent[1]])) { $tOutput = call_user_func($this->filters[$tContent[1]], $tOutput); } $this->output .= $tOutput; } $this->contents = []; } return $this->output; }