/** * {@inheritdoc} * * @return ClientView */ public function render(Request $request) { $actor = $request->getAttribute('actor'); $assets = $this->getAssets(); $locale = $this->locales->getLocale(); $localeCompiler = $locale ? $this->getLocaleCompiler($locale) : null; $view = new ClientView($this->api, $request, $actor, $assets, $this->layout, $localeCompiler); $view->setVariable('locales', $this->locales->getLocales()); $view->setVariable('locale', $locale); // Now that we've set up the ClientView instance, we can fire an event // to give extensions the opportunity to add their own assets and // translations. We will pass an array to the event which specifies // which translations should be included in the locale file. Afterwards, // we will filter all of the translations for the actor's locale and // compile only the ones we need. $keys = $this->translationKeys; $this->events->fire(new ConfigureClientView($this, $view, $keys)); if ($localeCompiler) { $translations = array_get($this->locales->getTranslator()->getMessages(), 'messages', []); $translations = $this->filterTranslations($translations, $keys); $localeCompiler->setTranslations($translations); } app('view')->share('translator', $this->locales->getTranslator()); return $view; }
/** * {@inheritdoc} * * @return ClientView */ public function render(Request $request) { $actor = $request->getAttribute('actor'); $assets = $this->getAssets(); $locale = $this->locales->getLocale(); $localeCompiler = $locale ? $this->getLocaleCompiler($locale) : null; $view = new ClientView($this->api, $request, $actor, $assets, $this->layout, $localeCompiler); $view->setVariable('locales', $this->locales->getLocales()); $view->setVariable('locale', $locale); $this->events->fire(new ConfigureClientView($this, $view)); if ($localeCompiler) { $translations = array_get($this->locales->getTranslator()->getMessages(), 'messages', []); $translations = $this->filterTranslations($translations); $localeCompiler->setTranslations($translations); } app('view')->share('translator', $this->locales->getTranslator()); return $view; }
/** * Get the string contents of the view. * * @param Request $request * @return string */ public function render(Request $request) { $forum = $this->getForumDocument($request); $this->view->share('translator', $this->locales->getTranslator()); $this->view->share('allowJs', !array_get($request->getQueryParams(), 'nojs')); $this->view->share('forum', array_get($forum, 'data')); $this->view->share('debug', array_get($forum, 'data.attributes.debug')); $view = $this->view->file(__DIR__ . '/../../../views/app.blade.php'); $view->title = $this->buildTitle(array_get($forum, 'data.attributes.title')); $view->description = $this->description; $view->modules = $this->modules; $view->payload = $this->buildPayload($request, $forum); $view->layout = $this->buildLayout(); $baseUrl = array_get($forum, 'data.attributes.baseUrl'); $view->cssUrls = $this->buildCssUrls($baseUrl); $view->jsUrls = $this->buildJsUrls($baseUrl); $view->head = implode("\n", $this->head); $view->foot = implode("\n", $this->foot); return $view->render(); }
/** * @param WebAppView $view */ private function addTranslations(WebAppView $view) { $translations = array_get($this->locales->getTranslator()->getMessages(), 'messages', []); $translations = $this->filterTranslations($translations); $view->getLocaleJs()->setTranslations($translations); }