2014-10-15 08:09:46 +11:00
|
|
|
<?php namespace System\Classes;
|
|
|
|
|
2015-02-23 19:55:06 +11:00
|
|
|
use Lang;
|
2015-01-28 18:03:35 +11:00
|
|
|
use ApplicationException;
|
2015-02-23 19:55:06 +11:00
|
|
|
use Illuminate\Routing\Controller as ControllerBase;
|
2014-10-15 08:09:46 +11:00
|
|
|
use Exception;
|
2019-02-27 15:33:48 -05:00
|
|
|
use Response;
|
2014-10-15 08:09:46 +11:00
|
|
|
|
|
|
|
/**
|
2017-03-16 17:08:20 +11:00
|
|
|
* The is the master controller for system related routing.
|
|
|
|
* It is currently only responsible for serving up the asset combiner contents.
|
2014-10-15 08:09:46 +11:00
|
|
|
*
|
2017-03-16 17:08:20 +11:00
|
|
|
* @see System\Classes\CombineAssets Asset combiner class
|
2014-10-15 08:09:46 +11:00
|
|
|
* @package october\system
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
2017-03-16 17:08:20 +11:00
|
|
|
class SystemController extends ControllerBase
|
2014-10-15 08:09:46 +11:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Combines JavaScript and StyleSheet assets.
|
|
|
|
* @param string $name Combined file code
|
|
|
|
* @return string Combined content.
|
|
|
|
*/
|
|
|
|
public function combine($name)
|
|
|
|
{
|
2014-10-18 11:58:50 +02:00
|
|
|
try {
|
|
|
|
if (!strpos($name, '-')) {
|
|
|
|
throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name' => $name]));
|
|
|
|
}
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2014-10-18 11:58:50 +02:00
|
|
|
$parts = explode('-', $name);
|
2019-03-29 06:02:06 +11:00
|
|
|
|
2014-10-18 11:58:50 +02:00
|
|
|
$cacheId = $parts[0];
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2015-01-12 20:08:31 +11:00
|
|
|
$combiner = CombineAssets::instance();
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2019-03-29 06:02:06 +11:00
|
|
|
return $combiner->getContents($cacheId);
|
2014-11-01 12:00:45 +11:00
|
|
|
}
|
|
|
|
catch (Exception $ex) {
|
2019-02-27 15:33:48 -05:00
|
|
|
return Response::make('/* '.e($ex->getMessage()).' */', 500);
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|
2014-10-15 08:09:46 +11:00
|
|
|
}
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|