예제 #1
0
파일: Queue.php 프로젝트: gandalf3/bolt
 /**
  * Add a file asset to the queue.
  *
  * @param FileAssetInterface $asset
  *
  * @throws \InvalidArgumentException
  */
 public function add(FileAssetInterface $asset)
 {
     $url = $this->packages->getUrl($asset->getPath(), $asset->getPackageName());
     $asset->setUrl($url);
     if ($asset->getType() === 'javascript') {
         $this->javascript[$url] = $asset;
     } elseif ($asset->getType() === 'stylesheet') {
         $this->stylesheet[$url] = $asset;
     } else {
         throw new \InvalidArgumentException(sprintf('Requested asset type %s is not valid.', $asset->getType()));
     }
 }
예제 #2
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']);
 }
예제 #3
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']);
 }