for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace samsonphp\minify;
use samson\core\ExternalModule;
use samsonphp\event\Event;
use samsonphp\resource\Router;
/**
* SamsonPHP minification module.
*
* @package SamsonPHP
* @author Vitaly Iegorov <[email protected]>
* @author Alexander Nazarenko <[email protected]>
* @author Nikita Kotenko <[email protected]>
*/
class Minify extends ExternalModule
{
* Module preparation stage.
* @return bool Preparation stage result
public function prepare()
Event::subscribe(Router::EVENT_CREATED, array($this, 'renderer'));
return parent::prepare();
}
* 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);