Exemplo n.º 1
0
 /**
  * New resource file update handler.
  *
  * @param string $type Resource type(extension)
  * @param string $content Resource content
  */
 public function renderer($type, &$content)
 {
     // If CSS resource has been updated
     if ($type === 'css') {
         // Read updated CSS resource file and compile it
         $content = CSSMin::process($content);
     } elseif ($type === 'js') {
         $content = JSMin::minify($content);
     }
 }
Exemplo n.º 2
0
 /**	@see ModuleConnector::init() */
 public function init(array $params = array())
 {
     // Pointer to resourcerouter
     $rr = m('resourcer');
     try {
         if (isset($rr->updated['js'])) {
             // Запишем новое содержание JS
             file_put_contents($rr->updated['js'], JSMin::minify(file_get_contents($rr->updated['js'])));
         }
         if (isset($rr->updated['css'])) {
             // Запишем новое содержание JS
             file_put_contents($rr->updated['css'], CSSMin::process(file_get_contents($rr->updated['css'])));
         }
     } catch (Exception $e) {
         e('Error minifying resource: ' . $e->getMessage());
     }
     // Вызовем родительский метод
     parent::init($params);
 }