public function executeWrite(\AgaviRequestDataHolder $request_data)
 {
     $report = array();
     try {
         $style = $request_data->getParameter('style', AgaviConfig::get('sass.style', 'compressed'));
         $themes = $request_data->getParameter('themes', []);
         $packer = new AssetCompiler();
         // just in case
         $packer->symlinkModuleAssets();
         if (empty($themes)) {
             $compilation_succeeded = $packer->compileThemes($style, $report);
         } else {
             foreach ($themes as $theme) {
                 $compilation_succeeded = $packer->compileTheme($theme, $style, $report);
             }
         }
         $compilation_succeeded &= $packer->compileModuleStyles($style, $report);
         $this->setAttribute('report', $report);
     } catch (\Exception $e) {
         $this->setAttribute('error', $e->getMessage());
         return 'Error';
     }
     if (!$compilation_succeeded) {
         return 'Error';
     }
     return 'Success';
 }
 public function executeWrite(\AgaviRequestDataHolder $request_data)
 {
     $report = array();
     $success = false;
     try {
         $optimize_style = $request_data->getParameter('optimize', AgaviConfig::get('requirejs.optimize_style', 'uglify2'));
         $buildfile_path = $request_data->getParameter('buildfile', AgaviConfig::get('requirejs.buildfile_path', AgaviConfig::get('core.pub_dir') . "/static/buildconfig.js"));
         $packer = new AssetCompiler();
         // just in case
         $packer->symlinkModuleAssets();
         // render buildconfig.js and put it into the target location for compilation
         $template_service = new ModuleTemplateRenderer();
         $buildconfig_content = $template_service->render('rjs/buildconfig.js');
         $success = file_put_contents($buildfile_path, $buildconfig_content, LOCK_EX);
         if (!$success) {
             $this->setAttribute('error', 'Could not write file: ' . $buildfile_path);
         }
         $success = $packer->compileJs($buildfile_path, $optimize_style, $report);
         $this->setAttribute('report', $report);
     } catch (\Exception $e) {
         $this->setAttribute('error', $e->getMessage());
         return 'Error';
     }
     if (!$success) {
         return 'Error';
     }
     return 'Success';
 }
 /**
  * @param array $parameters
  */
 public function __construct(array $parameters = array())
 {
     parent::__construct($parameters);
     $this->modules = array();
     foreach (AssetCompiler::getAvailableModuleDirectories() as $module_path) {
         $this->modules[basename($module_path)] = $module_path;
     }
 }
 public function executeWrite(\AgaviRequestDataHolder $request_data)
 {
     try {
         $style = $request_data->getParameter('style', AgaviConfig::get('sass.style', 'compressed'));
         $theme_name = $request_data->getParameter('theme', AgaviConfig::get('themes.default', 'honeybee-minimal'));
         $packer = new AssetCompiler();
         $packer->symlinkModuleAssets();
         $processes = array();
         if (!$request_data->getParameter('no-theme', false)) {
             $processes["Theme {$theme_name}"] = $packer->getWatchThemeProcess($theme_name, $style);
         }
         if (!$request_data->getParameter('no-modules', false)) {
             $processes = array_merge($processes, $packer->getWatchModuleStylesProcesses($style));
         }
         $this->setAttribute('processes', $processes);
     } catch (\Exception $e) {
         $this->setAttribute('error', $e->getMessage());
         return 'Error';
     }
     return 'Success';
 }
 public function embedAllMainModules()
 {
     $main_modules_for_rjs = '';
     $module_dirs = AssetCompiler::getAvailableModuleDirectories();
     foreach ($module_dirs as $module_path) {
         $module_name = basename($module_path);
         if (is_readable($module_path . "/assets/AllModules.js")) {
             if (empty($main_modules_for_rjs)) {
                 $main_modules_for_rjs .= "{name: \"{$module_name}/AllModules\"}";
             } else {
                 $main_modules_for_rjs .= ",{name: \"{$module_name}/AllModules\"}";
             }
         }
     }
     return $main_modules_for_rjs;
 }