getAdminPrefix() public method

Returns the normalize jarves_admin_prefix parameter.
public getAdminPrefix ( ) : string
return string
Esempio n. 1
0
 public function addMainResources($options = array())
 {
     $response = $this->pageStack->getPageResponse();
     $request = $this->pageStack->getRequest();
     $options['noJs'] = isset($options['noJs']) ? $options['noJs'] : false;
     $prefix = substr($this->jarves->getAdminPrefix(), 1);
     $response->addJs('
     window._path = window._baseUrl = ' . json_encode($request->getBasePath() . '/') . '
     window._pathAdmin = ' . json_encode($request->getBaseUrl() . '/' . $prefix . '/'), 3001);
     if ($this->jarves->isDebugMode()) {
         foreach ($this->jarves->getConfigs() as $bundleConfig) {
             foreach ($bundleConfig->getAdminAssetsInfo() as $assetInfo) {
                 if ($options['noJs'] && $assetInfo->isJavaScript()) {
                     continue;
                 }
                 $response->addAsset($assetInfo);
             }
         }
     } else {
         $response->addCssFile($prefix . '/admin/backend/css');
         if (!$options['noJs']) {
             $response->addJsFile($prefix . '/admin/backend/script', 3000);
         }
         foreach ($this->jarves->getConfigs() as $bundleConfig) {
             foreach ($bundleConfig->getAdminAssetsInfo() as $assetInfo) {
                 if ($options['noJs'] && $assetInfo->isJavaScript()) {
                     continue;
                 }
                 if ($assetInfo->getPath()) {
                     // load javascript files, that are not accessible (means those point to a controller)
                     // because those can't be compressed
                     $path = $this->jarves->resolveWebPath($assetInfo->getPath());
                     if (!file_exists($path)) {
                         $response->addAsset($assetInfo);
                         continue;
                     }
                 }
                 if ($assetInfo->getContent()) {
                     // load inline assets because we can't compress those
                     $response->addAsset($assetInfo);
                     continue;
                 }
                 if (!$assetInfo->isCompressionAllowed()) {
                     $response->addAsset($assetInfo);
                 }
             }
         }
     }
     $response->setDocType('JarvesBundle:Admin:index.html.twig');
     $response->addHeader('<meta name="viewport" content="initial-scale=1.0" >');
     $response->addHeader('<meta name="apple-mobile-web-app-capable" content="yes">');
     $response->setResourceCompression(false);
 }
Esempio n. 2
0
 /**
  * @ApiDoc(
  *  section="Backend",
  *  description="Prints all CSS files combined"
  * )
  *
  * @Rest\Get("/admin/backend/css")
  *
  * @return string CCS
  */
 public function loadCssAction()
 {
     $oFile = $this->jarves->getRootDir() . '/../web/cache/admin.style-compiled.css';
     $md5String = '';
     /** @var \Jarves\AssetHandler\Container $assetHandlerContainer */
     $assetHandlerContainer = $this->container->get('jarves.asset_handler.container');
     $files = [];
     foreach ($this->jarves->getConfigs() as $bundleConfig) {
         foreach ($bundleConfig->getAdminAssetsInfo() as $assetInfo) {
             if (!$assetInfo->isCompressionAllowed()) {
                 continue;
             }
             if ($assetInfo->isStylesheet()) {
                 $path = $this->jarves->resolveWebPath($assetInfo->getPath());
                 if (file_exists($path)) {
                     $files[] = $assetInfo->getPath();
                     $md5String .= filemtime($path);
                 }
             }
             if ($assetInfo->isScss()) {
                 $path = $this->jarves->resolveWebPath($assetInfo->getPath());
                 if (file_exists($path)) {
                     foreach ($assetHandlerContainer->compileAsset($assetInfo) as $subAssetInfo) {
                         $files[] = $subAssetInfo->getPath();
                     }
                     $md5String .= filemtime($path);
                 }
             }
         }
     }
     $handle = @fopen($oFile, 'r');
     $fileUpToDate = false;
     $md5Line = '/* ' . md5($md5String) . "*/\n";
     if ($handle) {
         $line = fgets($handle);
         fclose($handle);
         if ($line == $md5Line) {
             $fileUpToDate = true;
         }
     }
     if (!$fileUpToDate) {
         $content = $this->utils->compressCss($files, $this->jarves->getAdminPrefix() . 'admin/backend/');
         $content = $md5Line . $content;
         file_put_contents($oFile, $content);
     }
     $expires = 60 * 60 * 24 * 14;
     $response = new Response(file_get_contents($oFile));
     $response->headers->set('Content-Type', 'text/css');
     $response->headers->set('Pragma', 'public');
     $response->headers->set('Cache-Control', 'max-age=' . $expires);
     $response->headers->set('Expires', gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
     return $response;
 }