2014-10-14 21:09:46 +00:00
|
|
|
<?php namespace System\Classes;
|
|
|
|
|
|
|
|
|
|
use Controller as BaseController;
|
2015-01-28 07:03:35 +00:00
|
|
|
use ApplicationException;
|
2014-10-15 08:53:44 +00:00
|
|
|
use System\Classes\CombineAssets;
|
2014-10-14 21:09:46 +00:00
|
|
|
use Exception;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The System controller class.
|
|
|
|
|
*
|
|
|
|
|
* @package october\system
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
|
|
|
|
class Controller extends BaseController
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Combines JavaScript and StyleSheet assets.
|
|
|
|
|
* @param string $name Combined file code
|
|
|
|
|
* @return string Combined content.
|
|
|
|
|
*/
|
|
|
|
|
public function combine($name)
|
|
|
|
|
{
|
2014-10-18 09:58:50 +00:00
|
|
|
try {
|
2014-10-18 23:58:18 +00:00
|
|
|
|
2014-10-18 09:58:50 +00:00
|
|
|
if (!strpos($name, '-')) {
|
|
|
|
|
throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name' => $name]));
|
|
|
|
|
}
|
2014-10-18 23:58:18 +00:00
|
|
|
|
2014-10-18 09:58:50 +00:00
|
|
|
$parts = explode('-', $name);
|
|
|
|
|
$cacheId = $parts[0];
|
2014-10-18 23:58:18 +00:00
|
|
|
|
2015-01-12 09:08:31 +00:00
|
|
|
$combiner = CombineAssets::instance();
|
2014-10-18 09:58:50 +00:00
|
|
|
return $combiner->getContents($cacheId);
|
2014-10-18 23:58:18 +00:00
|
|
|
|
2014-11-01 01:00:45 +00:00
|
|
|
}
|
|
|
|
|
catch (Exception $ex) {
|
2014-10-18 09:58:50 +00:00
|
|
|
return '/* '.$ex->getMessage().' */';
|
|
|
|
|
}
|
2014-10-14 21:09:46 +00:00
|
|
|
}
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|