/** * Make the view content. * * @param PageInterface $page */ public function make(PageInterface $page) { $type = $page->getType(); /* @var EditorFieldType $layout */ $layout = $type->getFieldType('layout'); $page->setContent($this->view->make($layout->getViewPath(), compact('page'))->render()); }
public function anyUpload(InterfaceFileStorage $userFileStorage, AmqpWrapper $amqpWrapper, Server $server, UploadEntity $uploadEntity) { /* @var \App\Components\UserFileStorage $userFileStorage */ $responseVariables = ['uploadStatus' => false, 'storageErrors' => [], 'uploadEntities' => []]; if ($this->request->isMethod('post') && $this->request->hasFile('file') && $this->request->file('file')->isValid()) { $tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp-user-files-to-storage' . DIRECTORY_SEPARATOR; $tmpFilePath = $tmpDir . $this->request->file('file')->getClientOriginalName(); $this->request->file('file')->move($tmpDir, $this->request->file('file')->getClientOriginalName()); $userFileStorage->setValidationRules($this->config->get('storage.userfile.validation')); $newStorageFile = $userFileStorage->addFile($tmpFilePath); if ($newStorageFile && !$userFileStorage->hasErrors()) { /* @var \SplFileInfo $newStorageFile */ // AMQP send $newfile, to servers foreach ($server->all() as $server) { if (count($server->configs) > 0) { foreach ($server->configs as $config) { // Send server and file info to upload queue task $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $config->auth . '@' . $server->host . '/' . trim($config->path, '\\/')])); } } else { // The server has no configuration $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $server->host])); } } $responseVariables['uploadStatus'] = true; } else { $responseVariables['storageErrors'] = $userFileStorage->getErrors(); } if ($this->request->ajax()) { return $this->response->json($responseVariables); } } $responseVariables['uploadEntities'] = $uploadEntity->limit(self::UPLOAD_ENTITIES_LIMIT)->orderBy('created_at', 'DESC')->get(); return $this->view->make('upload.index', $responseVariables); }
public function getReset($token = null) { if (is_null($token)) { $this->application->abort(404); } return $this->view->make('UserManagement::password.reset')->with('token', $token); }
/** * Return an angular template partial. * * @param \App\Http\Requests\Api\Angular\TemplateRequest $request * @return \Illuminate\View\View */ public function template(TemplateRequest $request) { $template = $request->get('template'); if ($this->viewFactory->exists($template)) { return $this->viewFactory->make($template); } return $this->response()->errorNotFound(); }
/** * Displays the login form. */ public function getLogin() { $viewConfig = $this->config->get('l4-lock::config.lock.views'); if ($this->view->exists($viewConfig['foot-note'])) { $viewConfig['foot-note'] = $this->view->make($viewConfig['foot-note'])->render(); } return $this->view->make($this->config->get('l4-lock::config.lock.views.login'), array('view' => $viewConfig))->render(); }
/** * Parse some content. * * @param $content * @return string */ public function parse($content) { if (!$this->files->isDirectory($path = storage_path('framework/views/asset'))) { $this->files->makeDirectory($path); } $this->files->put(storage_path('framework/views/asset/' . (($filename = md5($content)) . '.twig')), $content); return $this->views->make('root::storage/framework/views/asset/' . $filename)->render(); }
/** * Returns all social sharing buttons. * * @return string */ public function all() { $defaultButtons = Config::get('shareable::default_buttons', array()); $buttons = array(); $output = ''; foreach ($defaultButtons as $button) { $buttons[] = call_user_func(array($this, $button)); } return $this->view->make('shareable::all', array('buttons' => $buttons)); }
/** * Handle incoming requests. * @param Request $request * @param \Closure $next * @return \Symfony\Component\HttpFoundation\Response */ public function handle($request, Closure $next) { if ($this->maintenance->isDownMode()) { if ($this->view->exists('errors.503')) { return new Response($this->view->make('errors.503'), 503); } return $this->app->abort(503, 'The application is down for maintenance.'); } return $next($request); }
/** * Composes a message. * * @return \Illuminate\View\Factory */ public function composeMessage() { // Attempts to make a view. // If a view can not be created; it is assumed that simple message is passed through. try { return $this->views->make($this->view, $this->data)->render(); } catch (\InvalidArgumentException $e) { return $this->view; } }
/** * Generate the target file from a stub. * * @param $stub * @param $targetLocation */ protected function compile($stub, $targetLocation) { $view = $this->view->make("generator.stubs::{$stub}", $this->context->toArray()); $contents = "<?php\r\n\r\n" . $view->render(); $targetDir = base_path('/SocialiteProviders/' . $this->context->nameStudlyCase()); if (!$this->files->isDirectory($targetDir)) { $this->files->makeDirectory($targetDir, 0755, true, true); $this->files->makeDirectory($targetDir . '/src', 0755, true, true); } $this->files->put($targetDir . '/' . $targetLocation, $contents); }
/** * @return mixed */ private function renderContent() { if (!$this->view->exists($this->template)) { $this->getFallBackTemplate(); } return $this->view->make($this->template, $this->data); }
/** * Render weather widget. * * @param array $options * @return string */ public function generate($options = array()) { // Get options $options = array_merge($this->config['defaults'], $options); // Unify units $options['units'] = strtolower($options['units']); if (!in_array($options['units'], array('metric', 'imperial'))) { $options['units'] = 'imperial'; } // Create cache key $cacheKey = 'Weather.' . md5(implode($options)); // Check cache if ($this->config['cache'] && $this->cache->has($cacheKey)) { return $this->cache->get($cacheKey); } // Get current weather $current = $this->getWeather($options['query'], 0, $options['units'], 1); if ($current['cod'] !== 200) { return 'Unable to load weather'; } // Get forecast $forecast = $this->getWeather($options['query'], $options['days'], $options['units']); // Render view $html = $this->view->make("{$this->config['views']}.{$options['style']}", array('current' => $current, 'forecast' => $forecast, 'units' => $options['units'], 'date' => $options['date']))->render(); // Add to cache if ($this->config['cache']) { $this->cache->put($cacheKey, $html, $this->config['cache']); } return $html; }
/** * Get the evaluated view contents for the given view. * * @param string $view * @param array $data * @param array $mergeData * @return \Illuminate\Contracts\View\View */ public function make($view, $data = [], $mergeData = []) { $normal_path = $this->normalizeName($view); $absolut_path = $this->finder->find($normal_path); $this->preparePath($absolut_path); $this->view = parent::make($view, $data, $mergeData); return $this->view; }
/** * Display fields on edit form screen. * * @param \stdClass $term The term object */ public function displayEditFields($term) { $this->setNonce(); foreach ($this->fields as $field) { $value = get_term_meta($term->term_id, $field['name'], true); $field['value'] = $this->getValue($term->term_id, $field, $value); echo $this->view->make('_themosisCoreTaxonomyEdit', ['field' => $field])->render(); } }
/** * We create the control input. * * @param $type * @param $name * @param null $value * @param array $attributes * @param array $options * @return \Illuminate\Contracts\View\View */ public function input($type, $name, $value = null, $attributes = [], $options = []) { $this->buildCssClasses($type, $attributes); $label = $this->buildLabel($name); $control = $this->buildControl($type, $name, $value, $attributes, $options); $error = $this->buildError($name); $icon = $this->buildIcon($attributes); $template = $this->buildTemplate($type, $attributes); return $this->view->make($template, compact('name', 'label', 'control', 'error', 'icon')); }
/** * Create a new migration. */ protected function createMigration() { $data = ['table' => $this->argument('table'), 'attachment' => $this->argument('attachment'), 'after' => $this->argument('after')]; $prefix = date('Y_m_d_His'); $fileName = $this->migrationsFolderPath . '/' . $prefix . '_add_' . $data['attachment'] . '_fields_to_' . $data['table'] . '_table.php'; $data['className'] = 'Add' . ucfirst(Str::camel($data['attachment'])) . 'FieldsTo' . ucfirst(Str::camel($data['table'])) . 'Table'; // Save the new migration to disk using the stapler migration view. $migration = $this->view->make('laravel-stapler::migration', $data)->render(); $this->file->put($fileName, $migration); // Dump the autoloader and print a created migration message to the console. $this->info("Created migration: {$fileName}"); }
/** * @param string $view * @param array $data * @param array $mergeData * @return \Illuminate\View\View */ public function make($view, $data = array(), $mergeData = array()) { $view = $this->stripFallbackFromPath($view); $themeView = $this->getActiveTheme() . '.' . $view; try { // check if view exists $this->finder->find($themeView); } catch (\InvalidArgumentException $e) { $themeView = $this->fallbackTheme . '.' . $view; } return parent::make($themeView, $data, $mergeData); }
/** * Execute the console command. * * @return void */ public function fire() { $bindings = array(); foreach ($this->getAbstracts() as $abstract) { try { $concrete = $this->laravel->make($abstract); if (is_object($concrete)) { $bindings[$abstract] = get_class($concrete); } } catch (\Exception $e) { $this->error("Cannot make {$abstract}: " . $e->getMessage()); } } $content = $this->view->make('laravel-ide-helper::meta', array('bindings' => $bindings, 'methods' => $this->methods))->render(); $filename = $this->option('filename'); $written = $this->files->put($filename, $content); if ($written !== false) { $this->info("A new meta file was written to {$filename}"); } else { $this->error("The meta file could not be created at {$filename}"); } }
/** * Handle the command. * * @param PageRepositoryInterface $pages * @return null|PageInterface */ public function handle(PageRepositoryInterface $pages, Factory $view) { $options = $this->options; /* @var PageCollection $pages */ $pages = $pages->sorted(); $pages = $pages->visible(); $this->dispatch(new SetParentRelations($pages)); $this->dispatch(new RemoveRestrictedPages($pages)); if ($root = $options->get('root')) { if ($page = $this->dispatch(new GetPage($root))) { $options->put('parent', $page); } } return $view->make($options->get('view', 'anomaly.module.pages::nav'), compact('pages', 'options'))->render(); }
/** * Make a view with the option to specify which theme you * would like to use. * * @param string $name * @param array $data * @param mixed $theme * @return \Illuminate\View\View * @throws \RuntimeException */ public function view($name, $data = array(), $theme = null) { if (!isset($this->view)) { throw new RuntimeException("Cannot make view [{$name}] from theme bag as the view factory has not been bound."); } if (!$theme) { return $this->view->make($name, $data); } $existingActive = $this->getActiveOrFail(); $tempActive = $this->ensureRegistered($theme); $this->setActive($tempActive); $view = $this->view->make($name, $data); $this->setActive($existingActive); return $view; }
/** * Create the migration. * * @param string $name * * @return bool */ public function createMigration($name, $view, $data = array()) { $this->line(''); $this->info('Creating migration...'); $camelName = ucwords(camel_case($name)); $data = array_merge(['name' => $camelName], $data); $output = $this->view->make("entrust::generators.{$view}")->with($data)->render(); $path = $this->getPath($name); if (!file_exists($path) && ($fs = fopen($path, 'x'))) { fwrite($fs, $output); fclose($fs); $this->info('Migration successfully created!'); return true; } $this->error("Couldn't create migration."); return false; }
/** * Return the HTML representation of the email to be sent. * * @return string */ public function getBody() { // Set the email's locale: $appLocale = $this->translator->getLocale(); if ($this->locale && $this->locale != $appLocale) { $this->translator->setLocale($this->locale); } // Generate HTML: $html = $this->viewFactory->make($this->view, $this->data)->render(); $css = $this->filesystem->get(base_path($this->cssFile)); $inliner = new CssToInlineStyles($html, $css); $body = $inliner->convert(); // Return App locale to former value: if ($this->locale && $this->locale != $appLocale) { $this->translator->setLocale($appLocale); } return $body; }
/** * Render widget to HTML. * * @throws UnknownWidgetFileException * @return string */ public function render() { if ($this->enable == false) { return ''; } $widgetDir = $this->config->get('theme.containerDir.widget'); $path = $this->theme->getThemeNamespace($widgetDir . '.' . $this->template); // If not found in theme widgets directory, try to watch in views/widgets again. if ($this->watch === true and !$this->view->exists($path)) { $path = $widgetDir . '.' . $this->template; } // Error file not exists. if (!$this->view->exists($path)) { throw new UnknownWidgetFileException("Widget view [{$this->template}] not found."); } $widget = $this->view->make($path, $this->data)->render(); return $widget; }
/** * Return a template with content. * * @param integer $statusCode * @throws UnknownLayoutFileException * @return Response */ public function render($statusCode = 200) { // Fire the event before render. $this->fire('after', $this); // Flush asset that need to serve. $this->asset->flush(); // Layout directory. $layoutDir = $this->getConfig('containerDir.layout'); $path = $this->getThemeNamespace($layoutDir . '.' . $this->layout); if (!$this->view->exists($path)) { throw new UnknownLayoutFileException("Layout [{$this->layout}] not found."); } $content = $this->view->make($path)->render(); // Append status code to view. $content = new Response($content, $statusCode); // Having cookie set. if ($this->cookie) { $content->withCookie($this->cookie); } return $content; }
/** * Get the evaluated view contents for the given view. * * @param string $view * @param array $data * @param array $mergeData * @return \Illuminate\Contracts\View\View * @static */ public static function make($view, $data = array(), $mergeData = array()) { return \Illuminate\View\Factory::make($view, $data, $mergeData); }
/** * Get the <script> block to render the calendar (as a View) * * @return \Illuminate\View\View */ public function script() { $options = $this->getOptionsJson(); return $this->view->make('fullcalendar::script', ['id' => $this->getId(), 'options' => $options]); }
/** * Add a view instance to the view data. * * @param string $key * @param string $view * @param array $data * @return $this */ public function nest($key, $view, array $data = []) { return $this->with($key, $this->factory->make($view, $data)); }
/** * Render the given view. * * @param string $view * @param array $data * @return \Illuminate\View\View */ protected function getView($view, $data) { return $this->views->make($view, $data)->render(); }
public function home() { $posts = Post::where('type', 1)->orderBy("id", 'desc')->take(5)->get(); $slides = $this->slider->get_images(5); return $this->view->make("Striped::index", compact('posts', 'slides')); }
/** * Get the pagination view. * * @param \Illuminate\Pagination\Paginator $paginator * @param string $view * @return \Illuminate\View\View */ public function getPaginationView(Paginator $paginator, $view = null) { $data = array('environment' => $this, 'paginator' => $paginator); return $this->view->make($this->getViewName($view), $data); }