/**
  * Adjust relative URLs in CSS content as if the file with this content is to be moved to new location
  *
  * @param string $cssContent
  * @param string $relatedPath
  * @param string $filePath
  * @return mixed
  */
 public function relocateRelativeUrls($cssContent, $relatedPath, $filePath)
 {
     $offset = FileSystem::offsetPath($relatedPath, $filePath);
     $callback = function ($path) use($offset) {
         return FileSystem::normalizePath($offset . '/' . $path);
     };
     return $this->replaceRelativeUrls($cssContent, $callback);
 }
Beispiel #2
0
 /**
  * Convert module notation to a path relative to the specified asset
  *
  * For example, the asset is Foo_Bar/styles/style.css and it refers to Bar_Baz::images/logo.gif
  * (i.e. url(Bar_Baz::images/logo.gif))
  * The result will be ../../Bar_Baz/images/logo.gif
  *
  * @param Asset\LocalInterface $thisAsset
  * @param string $relatedFileId
  * @return string
  */
 public function convertModuleNotationToPath(Asset\LocalInterface $thisAsset, $relatedFileId)
 {
     if (false === strpos($relatedFileId, Asset\Repository::FILE_ID_SEPARATOR)) {
         return $relatedFileId;
     }
     $thisPath = $thisAsset->getPath();
     $relatedAsset = $this->assetRepo->createSimilar($relatedFileId, $thisAsset);
     $relatedPath = $relatedAsset->getPath();
     $offset = FileSystem::offsetPath($relatedPath, $thisPath);
     return FileSystem::normalizePath($offset . '/' . basename($relatedPath));
 }
Beispiel #3
0
 /**
  * @param string $relatedPath
  * @param string $path
  * @param string $expectedResult
  * @dataProvider offsetPathDataProvider
  */
 public function testOffsetPath($relatedPath, $path, $expectedResult)
 {
     $result = $this->_model->offsetPath($relatedPath, $path);
     $this->assertEquals($expectedResult, $result);
 }