protected function resolveScriptIncludes() { parent::resolveScriptIncludes(); $includes = $this->getScriptIncludes(); $appWebPath = Environment::getVars()->get('appPackageWebPath'); //TODO /*$includes->addFile($appWebPath . '/deps/foo/foo.js', [ 'bundleKey' => 'app', ]);*/ }
public function handleException(Throwable $aEx) { $finalEx = $aEx; if ($finalEx instanceof UserFriendlyException) { //do nothing, as UserFriendlyException's are considered low-priority } else { //if the exception is due to an unresolved route if ($finalEx instanceof UnresolvedRouteException) { //interpret it as a 404, and wrap the original exception $finalEx = new HttpException($finalEx->getMessage(), $finalEx->getCode(), $finalEx, 404); } //log the error Env::getLogger()->error((string) $finalEx, ['requestId' => Env::getVars()->get('requestId'), 'exception' => $finalEx]); } //reboot to the 'Error' module. //We use the Error module to present error messages to the client $controller = static::boot(['moduleCode' => 'Error', 'nextRoute' => static::getInitialRoute(), 'hints' => ['app' => ['errorState' => ['error' => $finalEx]]]]); if ($controller) { $controller->connect(); $controller->run(); } }
public function getResolvedFiles() { $resolvedItems = []; ksort($this->items); foreach ($this->items as $groupIndex => $group) { $groupItemCounter = 0; foreach ($group as $item) { $resolvedUrl = null; $resolvedFileFilePath = null; //if the item is relative to the app or module if ($item['base'] == 'app' || $item['base'] == 'module') { $moduleCode = $this->view->getCode(); $chain = $this->view->getController()->getChain($moduleCode); if ($item['base'] == 'app') { $link = array_key_exists('app', $chain) ? $chain['app'] : null; } else { $link = array_key_exists('module', $chain) ? $chain['module'] : null; } if ($link) { $sourceDirUrl = Env::getVars()->get('appSourceWebPath') . '/' . str_replace('\\', '/', $link['namespace']); //if item specifies an explicit file path (relative to link) if ($item['filePath']) { //if file exists on disk if ($path = realpath($link['path'] . $item['filePath'])) { //if item's url is a url path if (mb_substr($item['url'], 0, 1) == '/') { $resolvedUrl = $sourceDirUrl . $item['url']; $resolvedFileFilePath = $path; } else { $resolvedUrl = $item['url']; } } } else { //if file exists on disk if ($path = realpath($link['path'] . $item['url'])) { $resolvedFileFilePath = $path; $resolvedUrl = $sourceDirUrl . $item['url']; } } } } else { //if we should check that the file exists in the filesystem if ($item['onlyIfExists']) { if ($item['filePath']) { if ($realPath = realpath($item['filePath'])) { $resolvedFileFilePath = $realPath; $resolvedUrl = $item['url']; } } else { if ($realPath = realpath($item['url'])) { $resolvedFileFilePath = $realPath; $resolvedUrl = $item['url']; } } } else { $resolvedUrl = $item['url']; } } if ($resolvedUrl) { $resolvedItem = $item; $resolvedItem['resolvedUrl'] = $resolvedUrl; $resolvedItem['resolvedFilePath'] = $resolvedFileFilePath; $resolvedItems[] = $resolvedItem; $groupItemCounter++; } } } return $resolvedItems; }
/** * Creates early-output <script> elements used to set up the script environment. * @return mixed|string * @throws \Exception */ public function createInitScriptElements() { $this->resolveJsEnvironment(); $depsPath = Env::getVars()->get('appDependenciesWebPath'); $jsSystemConfig = $this->getJsEnvironment()->get('systemConfig'); ob_start(); ?> <script type="text/javascript" src="<?php $this->out($depsPath . '/systemjs/systemjs/dist/system-csp-production.js'); ?> " class="appBootstrapScript"></script> <script type="text/javascript" class="appBootstrapScript"> <?php if ($jsSystemConfig) { ?> System.config(<?php echo JsonUtils::toJson($jsSystemConfig); ?> ); <?php } ?> window.define = System.amdDefine; window.require = System.amdRequire; </script> <?php $html = ob_get_clean(); $html = str_replace("\n", '', $html); $html = preg_replace('/\\s{2,}/', '', $html); return $html; }
public function handleResolveOptions() { $options = $this->getController()->getOptions(); $options->add('pagerPlugin.pagesDirectoryFilePath', Env::getVars()->get('projectPackageFilePath') . '/libs/static-pager'); }
public function handleException(Throwable $aEx) { Env::getLogger()->error((string) $aEx, ['requestId' => Env::getVars()->get('requestId'), 'exception' => $aEx]); Env::getStandardOutput()->write('FATAL ERROR: ' . $aEx->getMessage()); }
private function doLoad() { $model = $this->getModel(); $model->set('requestId', Environment::getVars()->get('requestId')); }