winter/modules/system/classes/SystemController.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?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;
use Exception;
use Response;
/**
* The is the master controller for system related routing.
* It is currently only responsible for serving up the asset combiner contents.
*
* @see System\Classes\CombineAssets Asset combiner class
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class SystemController extends ControllerBase
{
/**
* 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);
2014-10-18 11:58:50 +02:00
$cacheId = $parts[0];
2014-10-19 10:58:18 +11:00
$combiner = CombineAssets::instance();
2014-10-19 10:58:18 +11:00
return $combiner->getContents($cacheId);
}
catch (Exception $ex) {
return Response::make('/* '.e($ex->getMessage()).' */', 500);
2014-10-18 11:58:50 +02:00
}
}
2014-10-18 11:58:50 +02:00
}