/** * {@inheritdoc} */ public function setImportPath($fullPath, $relPath = null) { $this->_initCompiler(); if (!FS::isDir($fullPath)) { throw new Exception('Undefined import path: ' . $fullPath); } $fullPath = FS::getRelative($fullPath, $this->_options->get('root_path')); $this->_compiler->addImportDir($fullPath); }
/** * {@inheritdoc} */ public function setImportPath($fullPath, $relPath = null) { $this->_initCompiler(); $relPath = $relPath ?: $this->_options->get('root_url'); if (!FS::isDir($fullPath)) { throw new Exception('Undefined import path: ' . $fullPath); } $importPaths = \Less_Parser::$options['import_dirs']; $importPaths[$fullPath] = $relPath; $this->_compiler->SetImportDirs($importPaths); }
/** * @param array $options * @return Data * @throws Exception * @SuppressWarnings(PHPMD.Superglobals) */ protected function _prepareOptions(array $options) { // Default data for current system $this->_default['root_url'] = Url::root(); $this->_default['root_path'] = Sys::getDocRoot(); $options = array_merge($this->_default, $options); // Check cache directory $cachePath = FS::clean($options['cache_path']); if (!$cachePath) { throw new Exception('Option "cache_path" is empty!'); } if (!FS::isDir($cachePath)) { mkdir($cachePath, 0755, true); } $options['cache_path'] = FS::real($cachePath); $options['root_url'] = rtrim($options['root_url'], '/'); $options['root_path'] = FS::real($options['root_path']); $options['driver'] = ucfirst(strtolower(trim($options['driver']))); // Check mixin paths $lessFile = (array) $options['autoload']; foreach ($lessFile as $key => $mixin) { $lessFile[$key] = FS::real($mixin); } $options['autoload'] = array_filter($lessFile); // Check imported paths $importPaths = []; foreach ((array) $options['import_paths'] as $path => $uri) { if ($cleanPath = FS::real($path)) { $importPaths[$cleanPath] = $uri; } } $importPaths[$options['root_path']] = $options['root_url']; // Forced add root path in the end of list! $options['import_paths'] = array_filter($importPaths); return new Data($options); }
/** * Find theme path. * * @param string $name * @return null|string */ protected static function _find($name) { $paths = App::path('Plugin'); foreach ($paths as $path) { $path = FS::clean($path . '/', DS); $details = explode(DS, rtrim($path, DS)); $folder = Str::trim(array_pop($details)); $themeFolder = $path . $name; if (Arr::in($folder, self::$_skipFolder) || !FS::isDir($themeFolder)) { $themeFolder .= self::POSTFIX; } if (FS::isDir($themeFolder)) { return $themeFolder; } } return null; }
public function testIsDir() { isFalse(FS::isDir(__FILE__)); isTrue(FS::isDir(__DIR__)); }