RelativeCssPathFixer
This fixes import paths in CSS files if their location changes, e.g. when inlining or compressing css
This class is not part of the TYPO3 API.
Table of Contents
Methods
- __construct() : mixed
- fixRelativeUrlPaths() : string
- Fixes the relative paths inside of url() references in CSS files
- findAndReplaceUrlPathsByRegex() : string
- Finds and replaces all URLs by using a given regex
- resolveBackPath() : string
- Resolves "../" sections in the input path string.
Methods
__construct()
public
__construct(SystemResourceFactory $resourceFactory, SystemResourcePublisherInterface $resourcePublisher) : mixed
Parameters
- $resourceFactory : SystemResourceFactory
- $resourcePublisher : SystemResourcePublisherInterface
fixRelativeUrlPaths()
Fixes the relative paths inside of url() references in CSS files
public
fixRelativeUrlPaths(string $contents, string $newDir, ServerRequestInterface $request) : string
Parameters
- $contents : string
-
Data to process
- $newDir : string
-
directory referenced from current location
- $request : ServerRequestInterface
Return values
string —Processed data
findAndReplaceUrlPathsByRegex()
Finds and replaces all URLs by using a given regex
protected
findAndReplaceUrlPathsByRegex(string $contents, string $regex, string $newDir, string $wrap, ServerRequestInterface $request) : string
Parameters
- $contents : string
-
Data to process
- $regex : string
-
Regex used to find URLs in content
- $newDir : string
-
Path to prepend to the original file
- $wrap : string
-
Wrap around replaced values
- $request : ServerRequestInterface
Return values
string —Processed data
resolveBackPath()
Resolves "../" sections in the input path string.
protected
resolveBackPath(string $pathStr) : string
For example "fileadmin/directory/../other_directory/" will be resolved to "fileadmin/other_directory/"
Parameters
- $pathStr : string
-
File path in which "/../" is resolved