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;
|
2014-10-15 19:53:44 +11:00
|
|
|
use System\Classes\CombineAssets;
|
2015-02-23 19:55:06 +11:00
|
|
|
use Illuminate\Routing\Controller as ControllerBase;
|
2014-10-15 08:09:46 +11:00
|
|
|
use Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The System controller class.
|
|
|
|
*
|
|
|
|
* @package october\system
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
2015-02-05 19:47:20 +11:00
|
|
|
class Controller 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 {
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2014-10-18 11:58:50 +02:00
|
|
|
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);
|
|
|
|
$cacheId = $parts[0];
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2015-01-12 20:08:31 +11:00
|
|
|
$combiner = CombineAssets::instance();
|
2014-10-18 11:58:50 +02:00
|
|
|
return $combiner->getContents($cacheId);
|
2014-10-19 10:58:18 +11:00
|
|
|
|
2014-11-01 12:00:45 +11:00
|
|
|
}
|
|
|
|
catch (Exception $ex) {
|
2014-10-18 11:58:50 +02:00
|
|
|
return '/* '.$ex->getMessage().' */';
|
|
|
|
}
|
2014-10-15 08:09:46 +11:00
|
|
|
}
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|