2014-10-14 21:09:46 +00:00
|
|
|
<?php namespace System\Classes;
|
|
|
|
|
|
2015-02-23 08:55:06 +00:00
|
|
|
use Lang;
|
2015-01-28 07:03:35 +00:00
|
|
|
use ApplicationException;
|
2014-10-15 08:53:44 +00:00
|
|
|
use System\Classes\CombineAssets;
|
2015-02-23 08:55:06 +00:00
|
|
|
use Illuminate\Routing\Controller as ControllerBase;
|
2014-10-14 21:09:46 +00:00
|
|
|
use Exception;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The System controller class.
|
|
|
|
|
*
|
|
|
|
|
* @package october\system
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
2015-02-05 08:47:20 +00:00
|
|
|
class Controller extends ControllerBase
|
2014-10-14 21:09:46 +00:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2016-07-11 15:32:30 +00:00
|
|
|
return '/* '.e($ex->getMessage()).' */';
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|
2014-10-14 21:09:46 +00:00
|
|
|
}
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|