Streams view

@param string $view   Name of view file
@param array  $params Parameters supposed to be passed to the view
@return StreamedResponse
7426
protected function stream(string $view, array $params = []): StreamedResponse
    {
        $templateEngine = $this->getTemplateEngine();

        $callback = function () use ($templateEngine, $view, $params) {
            echo $templateEngine->render($view, $params);
        };

        $headers = $this->getResponse()->headers->all();

        return new StreamedResponse($callback, Response::HTTP_OK, $headers);
    }
773786
public function createView(RouterInterface $router, $route, $params)
    {
        $view = new View();

        $view->count = $this->getNbPages();
        $view->currentPage = $this->getCurrentPage();
        $view->pages = $this->getPagerLinks($router, $route, $params);
        /** @noinspection PhpParamsInspection */
        $view->first = reset($view->pages);
        /** @noinspection PhpParamsInspection */
        $view->last = end($view->pages);
        $view->next = $this->hasNextPage() ? $view->pages[$view->currentPage + 1] : null;
        $view->prev = $this->hasPreviousPage() ? $view->pages[$view->currentPage - 1] : null;

        return $view;
    }
636853
public function streamBlob($container, $name, $params = [])
    {
        $this->checkConnection();
        try {
            /** @var Container $container */
            $container = $this->blobConn->getContainer($container);
            if (empty($container)) {
                throw new \Exception("No container named '$container'");
            }

            $obj = $container->DataObject($name);

            header('Last-Modified: ' . $obj->getLastModified());
            header('Content-Type: ' . $obj->getContentType());
            header('Content-Length:' . $obj->getContentLength());

            $disposition =
                (isset($params['disposition']) && !empty($params['disposition'])) ? $params['disposition']
                    : 'inline';

            header('Content-Disposition: ' . $disposition . '; filename="' . $name . '";');
            $index = 0;
            $size = (integer)$obj->getContentLength();
            $chunk = \Config::get('df.file_chunk_size');
            ob_clean();

            while ($index < $size) {
                $header = ['Range' => 'bytes=' . $index . '-' . ($index + $chunk - 1)];
                /** @var \Guzzle\Http\Message\RequestInterface $result */
                $request = $container->getService()->getClient()->get($obj->getUrl(), $header);
                /** @var \Guzzle\Http\Message\Response $result */
                $result = $request->send();
                $length = $result->getContentLength();
                $index += $length;
                flush();
                echo $result->getBody();
            }
        } catch (\Exception $ex) {
            static::handleGuzzleException($ex);
            if ($ex instanceof ObjFetchError) {
                $code = HttpStatusCodes::HTTP_NOT_FOUND;
                $status_header = "HTTP/1.1 $code";
                header($status_header);
                header('Content-Type: text/html');
                echo 'Failed to stream/download file. File ' . $name . ' was not found. ' . $ex->getMessage();
            } else {
                throw new DfException('Failed to stream blob: ' . $ex->getMessage());
            }
        }
    }
1264219
protected function streamedResponse($callback = null, $status = 200, $headers = [])
    {
        $streamedResponse = new StreamedResponse($callback, $status, $headers);
        $streamedResponse->send();

        return $streamedResponse;
    }
845204
public function downloadFromView($view, array $parameters = array(),
        array $options = array())
    {
        $this->log(sprintf('Download pdf from view (%s).', $view));

        $contentDisposition = 'attachment; filename="' . $this->getName() . '"';
        return $this->generateResponse($view, $contentDisposition, $parameters,
            $options);
    }
657509
public function render($view, array $parameters = [], Response $response = null)
    {
        return $this->templating->renderResponse($view, $parameters, $response);
    }
1056814
protected function renderResponse($view, array $parameters = array(), Response $response = null)
    {
        return $this->get('templating')->renderResponse($view, $parameters, $response);
    }
290878
public function view($view, $data = [], $status = 200, array $headers = [])
    {
        respondWith(response()->view($view, $data, $status, $headers ));
    }
1373604
public function view($view, $data = [], $mergeData = [])
    {
        return $this->app['view']->make($this->viewname($view), $data, $mergeData);
    }
883227
public function render($view, $params = [])
  {
    // Check empty $params or not
    if (isset($params)) {
      $this->params = $params;
    }

    // Init Twig Template Engine   
    $loader = new \Twig_Loader_Filesystem('templates/');
    $twig = new \Twig_Environment($loader, array(
        'cache' => false
    ));

    // Default Global var and classes
    $twig->addGlobal('middleware', new Middleware());
    $twig->addGlobal('csrf_token', CsrfSecurity::generateCsrfToken());
    $twig->addGlobal('homePath', siteURL());

    // Add global var for all templates
    foreach($this->addGlobal as $addGlobal) {
       $twig->addGlobal($addGlobal['name'], $addGlobal['globalVar']);
    }

    // Add global Class for all templates
    foreach($this->addGlobalClass as $addGlobalClass) {
      $twig->addGlobal($addGlobalClass['name'], new $addGlobalClass['globalClass']());
    }

    // Render template
    echo $twig->render($view . '.tmp', $this->params);
  }
825076
public function getOutputFromView($view, array $parameters = array(),
        array $options = array())
    {
        $this->log(sprintf('Get converted output from view (%s).', $view));

        $html = $this->getTemplatingEngine()->render($view, $parameters);

        return $this->getOutputFromHtml($html, $options);
    }
1129329
protected function renderTemplate($view, array $parameters, $checksum)
    {
        $view = sprintf('%s_%s', $view, $checksum);

        return $this->renderer->renderTemplate($view, $parameters);
    }
932599
public static function view($view, $data = array(), $status = 200, array $headers = array())
	{
		$app = Facade::getFacadeApplication();

		return static::make($app['view']->make($view, $data), $status, $headers);
	}
390886
protected function runTemplate($method, array $params=[]) {
		ob_start();
		$result         = call_user_func_array([$this, $method], $params);
		$viewableBuffer = ob_get_clean();

		#result returned by method?
		if($result !== null) {
			if($result instanceof TemplateInterface) {
				if(!$result->getEngine() && $this->templateEngine)
					$result->setEngine($this->templateEngine);
				return $result->render();
			}
			elseif(is_numeric($result))
				return (string)$result;
			else
				return $result;
		}
		#output from method?
		elseif($viewableBuffer)
			return $viewableBuffer;
		#given view?
		elseif($this->view) {
			#given template engine?
			if($this->templateEngine)
				return $this->templateEngine->createTemplate()->render($this->view, (array)$this);
			#use the default render technique
			else
				return $this->renderDefaultTemplate($this->view, (array)$this);
		}
		#default view
		elseif($this->defaultView) {
			#given template engine?
			if($this->templateEngine) {
				$engine = $this->templateEngine;
				if($engine->templateExists($this->defaultView))
					return $engine->createTemplate()->render($this->defaultView, (array)$this);
			}
			#use the default render technique
			elseif($this->templateExists($this->defaultView))
				return $this->renderDefaultTemplate($this->defaultView, (array)$this);
		}
		#nothing to return
		return null;
	}
1130200
public function addStreamFilter(string $filtername, $params = null): self
    {
        if (!$this->document instanceof Stream) {
            throw new Exception('The stream filter API can not be used');
        }

        $this->document->appendFilter($filtername, $this->stream_filter_mode, $params);
        $this->stream_filters[$filtername] = true;
        $this->resetProperties();
        $this->input_bom = null;

        return $this;
    }
683878
public function fetch($view, array $data = [])
    {
        $file = $this->getViewFile($view);

        if (!is_file($file)) {
            throw new \RuntimeException("cannot render '$view' because the view file does not exist. File: $file");
        }

        /*
        foreach ($data as $k=>$val) {
            if (in_array($k, array_keys($this->attributes))) {
                throw new \InvalidArgumentException("Duplicate key found in data and renderer attributes. " . $k);
            }
        }
        */
        $data = array_merge($this->attributes, $data);

        try {
            ob_start();
            $this->protectedIncludeScope($file, $data);
            $output = ob_get_clean();
        } catch (\Throwable $e) { // PHP 7+
            ob_end_clean();
            throw $e;
        }

        return $output;
    }
1225352
protected function loadView($view, $values = [])
    {


        if (isset($this->application[$view])) {
            return $this->application[$view];
        }

        $instance = $this->application->createInstance($view, [$values, $this->response, $this->getHandler()]);

        //Otherwise return an instance of Controller;
        return $this->application->shareInstance($instance, $view);
    }