method get documentation in bbn\Mvc\View
Processes the controller and checks whether it has been routed or not.
function(array $data = NULL)
{
if ($this->check()) {
if (\is_null($this->_content) && is_file($this->_file)) {
$this->_content = file_get_contents($this->_file);
}
if (empty($this->_content)) {
return '';
}
if ($this->_checkers) {
$st = '';
foreach ($this->_checkers as $chk){
if (is_file($chk)) {
$st .= file_get_contents($chk);
}
}
$this->_content = $st.$this->_content;
}
switch ($this->_ext){
case 'js':
// Language variables inclusions in the javascript files
if (!empty($this->_lang_file) && is_file($this->_lang_file)) {
$tmp = json_decode(file_get_contents($this->_lang_file), true);
$path = $this->_plugin && !$this->_component ? substr($this->_path, \strlen($this->_plugin) + 1) : $this->_path;
//die(var_dump(count($tmp), 'components/'.$this->path.'/'.$this->path, $tmp));
$idx = $this->_component ? 'components/' : 'mvc/';
//die(var_dump($idx.$path, $tmp));
//die(var_dump($idx.$path, $this->_path, $this->_plugin, $this->_component, array_keys($tmp)));
//die(var_dump($idx.$path, $tmp));
if ($translations = ($tmp[$idx.$path] ?? null)) {
$json = json_encode($translations);
$tmp = << {
if (!!bbn.env && bbn.env.isInit) {
bbn.fn.autoExtend("lng", $json);
}
else {
document.addEventListener('bbninit', () => {
bbn.fn.autoExtend("lng", $json);
}, {once: true});
}
})();
JAVASCRIPT;
$this->_content = $tmp.$this->_content;
}
unset($tmp, $translations, $json);
}
$tmp = false;
try {
if (!defined('BBN_IS_DEV') || !BBN_IS_DEV) {
$tmp = \JShrink\Minifier::minify($this->_content, ['flaggedComments' => false]);
}
}
catch (\RuntimeException $e){
\bbn\X::log([$e->getMessage(), $this->_file], 'js_shrink');
}
return $tmp ?: $this->_content;
case 'css':
return $this->_content;
case 'less':
if ($this->_component_name) {
$this->_content = '@componentName: '.$this->_component_name.';'.PHP_EOL.$this->_content;
}
$less = new \bbn\Compilers\Less();
return $less->compile($this->_content);
case 'scss':
$scss = new \ScssPhp\ScssPhp\Compiler();
return $scss->compile($this->_content);
case 'html':
return empty($data) ? $this->_content : bbn\Tpl::render($this->_content, $data);
case 'php':
$dir = getcwd();
/** @todo explain why */
chdir(X::dirname($this->_file));
if ($this->_plugin &&
($router = Router::getInstance()) &&
($textDomain = $router->getLocaleDomain($this->_plugin_name))
) {
$oldTextDomain = textdomain(null);
if ($textDomain !== $oldTextDomain) {
textdomain($textDomain);
}
else {
unset($oldTextDomain);
}
}
$r = bbn\Mvc::includePhpView($this->_file, $this->_content, $data ?: []);
if (!empty($oldTextDomain)) {
textdomain($oldTextDomain);
}
chdir($dir);
return $r;
}
}
return false;
}
Processes the controller and checks whether it has been routed or not. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions