winter/modules/system/classes/Controller.php

42 lines
992 B
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;
use System\Classes\CombineAssets;
2015-02-23 19:55:06 +11:00
use Illuminate\Routing\Controller as ControllerBase;
use Exception;
/**
* The System controller class.
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class Controller 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 {
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
$combiner = CombineAssets::instance();
2014-10-18 11:58:50 +02:00
return $combiner->getContents($cacheId);
2014-10-19 10:58:18 +11:00
}
catch (Exception $ex) {
2014-10-18 11:58:50 +02:00
return '/* '.$ex->getMessage().' */';
}
}
2014-10-18 11:58:50 +02:00
}