Netgusto\PortalBundle\Twig\PortalExtension::reactwebpack PHP Method

reactwebpack() protected method

$sfdir = realpath($this->container->getParameter('kernel.root_dir') . '/../'); $apppath = realpath($sfdir . '/' . $app['path']); $webdir = realpath($sfdir . '/web'); $debug = $this->container->getParameter('kernel.debug'); if($debug) { $url = 'http://0.0.0.0:' . (array_key_exists('port', $app) ? $app['port'] : '4200'); $content = file_get_contents($url); $assetprefix = $url; } else { $content = file_get_contents($apppath . '/dist/index.html'); $relapppath = preg_replace('%^' . preg_quote($webdir) . '%', '', $apppath); $assetprefix = $relapppath . '/dist'; } $assetprefix = rtrim($assetprefix, '/') . '/'; # On récupère la balise meta config/environment $kept = array(); $kept[] = $this->produceConfigurationMeta($content, $options, function($config) { $config['locationType'] = 'hash'; return $config; }); $parts = $this->extractAppAndRewriteAssetsUrl($content, $assetprefix, $kept); return new PortalApplicationResponse($parts['assets'], $parts['html']); }
protected reactwebpack ( $app, $options = [] )
    protected function reactwebpack($app, $options = array())
    {
        $debug = $this->container->getParameter('kernel.debug');
        if ($debug) {
            $resAssets = '<script type="text/javascript" src="//0.0.0.0:' . intval($app['port']) . '/assets/main.js"></script>';
        } else {
            $resAssets = '<script type="text/javascript" src="/' . htmlspecialchars($app['dist']) . '"></script>';
        }
        $resHtml = $this->produceConfigurationMeta($options);
        return new PortalApplicationResponse($resAssets, $resHtml);
    }