Beispiel #1
0
 /**
  * Updates variables.less with the values given in the request.
  *
  * @param ServiceBase $api
  * @param array $args
  *
  * @return array Locations of CSS files
  * @throws SugarApiExceptionNotAuthorized
  * @throws SugarApiExceptionMissingParameter
  */
 public function updateCustomTheme(ServiceBase $api, array $args)
 {
     if (!$api->user->isAdmin()) {
         throw new SugarApiExceptionNotAuthorized();
     }
     if (empty($args)) {
         throw new SugarApiExceptionMissingParameter('Missing colors');
     }
     // Validating arguments
     $platform = isset($args['platform']) ? $args['platform'] : 'base';
     $themeName = isset($args['themeName']) ? $args['themeName'] : null;
     $theme = new SidecarTheme($platform, $themeName);
     // if reset=true is passed
     if (!empty($args['reset'])) {
         $theme->saveThemeVariables($args['reset']);
     } else {
         // else
         $theme->loadVariables();
         // Override the custom variables.less with the given vars
         $variables = array_diff_key($args, array('platform' => 0, 'themeName' => 0, 'reset' => 0));
         $theme->setVariables($variables);
         $theme->saveThemeVariables();
     }
     // saves the bootstrap.css URL in the portal settings
     $urls = $theme->getCSSURL();
     foreach ($urls as $key => $url) {
         $urls[$key] = $GLOBALS['sugar_config']['site_url'] . '/' . $url;
     }
     $GLOBALS['system_config']->saveSetting($platform, 'css', json_encode($urls));
     return $urls;
 }