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;
|
2018-08-24 17:40:40 +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;
|
|
|
|
|
|
|
|
|
|
/**
|
2017-03-16 06:08:20 +00:00
|
|
|
* The is the master controller for system related routing.
|
|
|
|
|
* It is currently only responsible for serving up the asset combiner contents.
|
2014-10-14 21:09:46 +00:00
|
|
|
*
|
2017-03-16 06:08:20 +00:00
|
|
|
* @see System\Classes\CombineAssets Asset combiner class
|
2014-10-14 21:09:46 +00:00
|
|
|
* @package october\system
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
2017-03-16 06:08:20 +00:00
|
|
|
class SystemController 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
|
|
|
}
|