예제 #1
0
파일: AssetTrait.php 프로젝트: html2k/bolt
 /**
  * Set up an asset.
  *
  * @param FileAssetInterface $asset
  * @param string             $fileName
  * @param array              $options
  */
 private function setupAsset(FileAssetInterface $asset, $fileName, array $options)
 {
     $fileName = $this->getAssetPath($fileName);
     $options = array_merge(['late' => false, 'priority' => 0, 'attrib' => null], $this->getCompatibleArgs($options));
     $asset->setFileName($fileName)->setLate($options['late'])->setPriority($options['priority'])->setAttributes($options['attrib']);
     return $asset;
 }
예제 #2
0
파일: Queue.php 프로젝트: d-m-/bolt
 /**
  * Process a single asset.
  *
  * @param FileAssetInterface $asset
  * @param Request            $request
  * @param Response           $response
  */
 protected function processAsset(FileAssetInterface $asset, Request $request, Response $response)
 {
     if ($asset->getZone() !== Zone::get($request)) {
         return;
     } elseif ($asset->isLate()) {
         $this->injector->inject($asset, Target::END_OF_BODY, $response);
     } elseif ($asset->getType() === 'stylesheet') {
         $this->injector->inject($asset, Target::BEFORE_CSS, $response);
     } elseif ($asset->getType() === 'javascript') {
         $this->injector->inject($asset, Target::AFTER_JS, $response);
     }
 }
예제 #3
0
파일: AssetTrait.php 프로젝트: bolt/bolt
 /**
  * Normalizes the path and package name of the asset file.
  *
  * @param FileAssetInterface $asset
  */
 private function normalizeAsset(FileAssetInterface $asset)
 {
     $path = $asset->getPath();
     if ($path === null) {
         throw new \RuntimeException('Extension file assets must have a path set.');
     }
     if ($this->isAbsoluteUrl($path)) {
         // Set asset to a package, since there is no default.
         // It doesn't matter which since it is absolute.
         $asset->setPackageName('extensions');
         return;
     }
     $file = $this->getWebDirectory()->getFile($asset->getPath());
     if ($file->exists()) {
         $asset->setPackageName('extensions')->setPath($file->getPath());
         return;
     }
     $app = $this->getContainer();
     $themeFile = $app['filesystem']->getFile(sprintf('theme://%s', $path));
     if ($themeFile->exists()) {
         $asset->setPackageName('theme')->setPath($path);
         return;
     }
     $message = sprintf("Couldn't add file asset '%s': File does not exist in either %s or %s directories.", $path, $this->getWebDirectory()->getFullPath(), $themeFile->getFullPath());
     $app['logger.system']->error($message, ['event' => 'extensions']);
 }
예제 #4
0
파일: Queue.php 프로젝트: gandalf3/bolt
 /**
  * Process a single asset.
  *
  * @param FileAssetInterface $asset
  * @param Request            $request
  * @param Response           $response
  */
 protected function processAsset(FileAssetInterface $asset, Request $request, Response $response)
 {
     if ($asset->getZone() !== Zone::get($request)) {
         return;
     } elseif ($asset->isLate()) {
         if ($asset->getLocation() === null) {
             $location = Target::END_OF_BODY;
         } else {
             $location = $asset->getLocation();
         }
     } elseif ($asset->getLocation() !== null) {
         $location = $asset->getLocation();
     } else {
         $location = Target::END_OF_HEAD;
     }
     $this->injector->inject($asset, $location, $response);
 }
예제 #5
0
파일: Queue.php 프로젝트: atiarda/bolt
 /**
  * Process the JavaScript asset queue.
  *
  * @param FileAssetInterface $asset
  * @param string             $html
  *
  * @return string
  */
 protected function processJsAssets(FileAssetInterface $asset, $html)
 {
     if ($asset->isLate()) {
         return $this->injector->inject($asset, Target::END_OF_BODY, $html);
     } else {
         return $this->injector->inject($asset, Target::AFTER_JS, $html);
     }
 }
예제 #6
0
 /**
  * Normalizes the path and package name of the asset file.
  *
  * @param FileAssetInterface $asset
  */
 private function normalizeAsset(FileAssetInterface $asset)
 {
     $path = $asset->getPath();
     if ($path === null) {
         throw new \RuntimeException('Extension file assets must have a path set.');
     }
     $file = $this->getWebDirectory()->getFile($asset->getPath());
     if ($file->exists()) {
         $asset->setPackageName('extensions')->setPath($file->getPath());
         return;
     }
     $app = $this->getContainer();
     if ($app['filesystem']->has(sprintf('theme://%s', $path))) {
         $asset->setPackageName('theme')->setPath($path);
         return;
     }
     $message = sprintf("Couldn't add file asset '%s': File does not exist in either %s or %s directories.", $path, $this->getWebDirectory()->getFullPath(), $app['resources']->getUrl('theme'));
     $app['logger.system']->error($message, ['event' => 'extensions']);
 }