relativePath = self::ASSET_DIRECTORY; } /** * Add JavaScript files to local repository * * @param array $fileNames */ public function registerScriptFiles($fileNames = array()) { foreach($fileNames as $row) { $this->_scripts[] = $row; } } /** * Add style files to local repository * * @param array $fileNames */ public function registerStyleFiles($fileNames = array()) { foreach($fileNames as $row) { $this->_styles[] = $row; } } /** * Get JavaScript file content * * @param $fileName * @return string */ public function getScriptFileContent($fileName) { return $this->getFileContent($fileName, self::SCRIPT_EXT); } /** * Get style file content * * @param $fileName * @return string */ public function getStyleFileContent($fileName) { return $this->getFileContent($fileName, self::STYLE_EXT); } /** * Get file content by extension * * @param $fileName * @param $fileExtension * @param bool $registration Is registration of files needed ? * @return string * @throws Exception */ public function getFileContent($fileName, $fileExtension, $registration = true) { $content = ''; $filePath = SELECTOR_ROOT_DIR . DS . self::ASSET_DIRECTORY . DS . $fileName; $filePath .= $fileExtension === 'font' ? '' : '.' . $fileExtension; if (file_exists($filePath)) { if (!$registration) { return file_get_contents($filePath); } elseif (in_array($fileName, $this->_styles) || in_array($fileName, $this->_scripts)) { return file_get_contents($filePath); } } else { throw new Exception("REQUIRED FILE \"$fileName\" DOES NOT EXIST IN $fileExtension"); } return $content; } }