/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // Inits sfLESS instance for compilation help $less = new sfLESS(new sfLESSConfig(false, isset($options['compress']) && $options['compress'])); // Remove old CSS files if --clean option specified if (isset($options['clean']) && $options['clean']) { foreach ($less->findCssFiles() as $cssFile) { if (!isset($arguments['file']) || false !== strpos($cssFile, $arguments['file'] . '.css')) { unlink($cssFile); $this->logSection('removed', str_replace(sfLESS::getConfig()->getCssPaths(), '', $cssFile)); } } } // Outputs debug info if (isset($options['debug']) && $options['debug']) { foreach (sfLESS::getConfig()->getDebugInfo() as $key => $value) { $this->logSection('debug', sprintf("%s:\t%s", $key, $value), null, 'INFO'); } } // Compiles LESS files foreach ($less->findLessFiles() as $lessFile) { if (!isset($arguments['file']) || false !== strpos($lessFile, $arguments['file'] . '.less')) { if ($less->compile($lessFile)) { if (isset($options['debug']) && $options['debug']) { $this->logSection('compiled', sprintf("%s => %s", sfLESSUtils::getProjectRelativePath($lessFile), sfLESSUtils::getProjectRelativePath($less->getCssPathOfLess($lessFile))), null, 'COMMAND'); } else { $this->logSection('compiled', str_replace(sfLESS::getConfig()->getLessPaths(), '', $lessFile), null, 'COMMAND'); } } } } }
/** * Listens to the routing.load_configuration event. Finds & compiles LESS files to CSS * * @param sfEvent $event an sfEvent instance */ public static function findAndCompile(sfEvent $event) { // Start compilation timer for debug info $timer = sfTimerManager::getTimer('Less compilation'); // Create new helper object & compile LESS stylesheets with it $less = new sfLESS(); foreach ($less->findLessFiles() as $lessFile) { $less->compile($lessFile); } // Stop timer $timer->addTime(); }