ThemeWriter
in package
implements
ThemeWriterInterface
Class ThemeWriter publish theme and create cache and compile template 5.55 s publish theme and compile template 3.62 s compile template 2.63, 2.78, 2.69, normal 0.676s
Interfaces, Classes and Traits
- ThemeWriterInterface
- Interface ThemeWriterInterface
Table of Contents
- FILE_IS_SCRIPT_OR_SHEET_PATTERN = '#\.(css|js)$#i'
- HTML_SYSTEM_DIRECTORY = 'html/system'
- JS_SYSTEM_DIRECTORY = 'javascripts/system'
- SETTINGS_FILENAME = 'settings.json'
- UNMINIFIED_FILE_NAME_PATTERN = '#(\.min)?\.(css|js)$#i'
- $filesystem : FilesystemAdapter
- $shopSource : string
- $sourceThemeId : ThemeId
- $themeExtensionFiles : array<string|int, mixed>
- $themeSettingsFactory : ThemeSettingsDataFactory
- __construct() : mixed
- ThemeWriter constructor.
- getPaths() : array<string|int, mixed>
- save() : void
- Saves the given them to the destination.
- _appendFileContent() : void
- _applyActiveThemeVariants() : bool|CustomThemeCopyResponse
- _applyGxModulesCustomOverloads() : void
- _applyHtmlOverloads() : bool|CustomThemeCopyResponse
- _chmod() : void
- _copyBaseThemeFiles() : CustomThemeCopyResponse
- _copyCustomHtmlDirectory() : bool|CustomThemeCopyResponse|mixed
- _copyCustomJsDirectory() : void
- _copyCustomStylesDirectory() : void
- _copyFile() : void
- _copyGxModulesExtensionsForTheme() : bool|CustomThemeCopyResponse
- _copyMainThemeDirectory() : void
- _copyMainThemeFile() : void
- _copyOrReplaceFile() : void
- _copyOrReplaceThemeFile() : void
- _copySettingsJson() : void
- _copyStyleEditThemeDirectory() : void
- _copyThemeDirectory() : void
- _copyThemeFontsDirectory() : void
- _copyThemeImagesDirectory() : void
- _copyThemeJson() : void
- _duplicateFilesThatHaveNoMatchingMinOrSourceFile() : void
- Creates a duplicate of a file with .min if only the source file exists or a file without .min if only the .min file exists
- _endsWith() : bool
- _extendHtmlFile() : mixed
- _findFilesThatHaveNoMatchingMinOrSourceFile() : void
- Checks the $themeDirectoryRoot (/public/theme) for files that have no matching source or .min file
- _findScriptsAndSheetsInDirectory() : array<string|int, string>
- _getRelative() : mixed
- _getRelativeFromDir() : string
- _getRelativeFromFile() : string
- _loadActiveVariants() : ConfigurationCollection
- _moveJsFromCustomRootDirectoryToCustomGlobalDirectory() : string
- Modifies the path if a file would be placed inside the root of the custom directory. The file will be moved inside the global directory of system directory
- _replaceCustomInPath() : string
- _saveMainTheme() : void
- _saveTheme() : bool|CustomThemeCopyResponse|mixed
- _saveThemeStructure() : void
- _stringAfter() : bool|string
- _stringReplaceFirst() : string
- recursiveChmod() : void
Constants
FILE_IS_SCRIPT_OR_SHEET_PATTERN
protected
mixed
FILE_IS_SCRIPT_OR_SHEET_PATTERN
= '#\.(css|js)$#i'
HTML_SYSTEM_DIRECTORY
protected
mixed
HTML_SYSTEM_DIRECTORY
= 'html/system'
JS_SYSTEM_DIRECTORY
protected
mixed
JS_SYSTEM_DIRECTORY
= 'javascripts/system'
SETTINGS_FILENAME
protected
mixed
SETTINGS_FILENAME
= 'settings.json'
UNMINIFIED_FILE_NAME_PATTERN
protected
mixed
UNMINIFIED_FILE_NAME_PATTERN
= '#(\.min)?\.(css|js)$#i'
Properties
$filesystem
protected
FilesystemAdapter
$filesystem
$shopSource
protected
string
$shopSource
$sourceThemeId
protected
ThemeId
$sourceThemeId
$themeExtensionFiles
protected
array<string|int, mixed>
$themeExtensionFiles
$themeSettingsFactory
private
ThemeSettingsDataFactory
$themeSettingsFactory
Methods
__construct()
ThemeWriter constructor.
public
__construct(FilesystemAdapter $filesystem, ExistingDirectory $shopSource, array<string|int, mixed> $themeExtensionFiles, ThemeSettingsDataFactory $themeSettingsFactory) : mixed
Parameters
- $filesystem : FilesystemAdapter
- $shopSource : ExistingDirectory
- $themeExtensionFiles : array<string|int, mixed>
- $themeSettingsFactory : ThemeSettingsDataFactory
Return values
mixed —getPaths()
public
getPaths(ThemeId $themeId, ThemeDirectoryInterface $directory, ThemeDirectoryRootInterface $destination) : array<string|int, mixed>
Parameters
- $themeId : ThemeId
- $directory : ThemeDirectoryInterface
- $destination : ThemeDirectoryRootInterface
Return values
array<string|int, mixed> —save()
Saves the given them to the destination.
public
save(ThemeInterface $theme, ThemeDirectoryRootInterface $destination) : void
Parameters
- $theme : ThemeInterface
-
Theme to be saved.
- $destination : ThemeDirectoryRootInterface
-
Destination directory.
Tags
Return values
void —_appendFileContent()
protected
_appendFileContent( $destinationFile, $sourceFile) : void
Parameters
Return values
void —_applyActiveThemeVariants()
protected
_applyActiveThemeVariants(IdentifiedThemeInterface $theme, ThemeDirectoryRootInterface $destination, ConfigurationCollection $variants) : bool|CustomThemeCopyResponse
Parameters
- $theme : IdentifiedThemeInterface
- $destination : ThemeDirectoryRootInterface
- $variants : ConfigurationCollection
Tags
Return values
bool|CustomThemeCopyResponse —_applyGxModulesCustomOverloads()
protected
_applyGxModulesCustomOverloads(MainThemeInterface $mainTheme, array<string|int, mixed> $childThemes, ThemeDirectoryRootInterface $destination) : void
Parameters
- $mainTheme : MainThemeInterface
- $childThemes : array<string|int, mixed>
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_applyHtmlOverloads()
protected
_applyHtmlOverloads(CustomThemeCopyResponse $overloaders, ThemeDirectoryRootInterface $destination, ThemeId $themeId) : bool|CustomThemeCopyResponse
Parameters
- $overloaders : CustomThemeCopyResponse
- $destination : ThemeDirectoryRootInterface
- $themeId : ThemeId
Tags
Return values
bool|CustomThemeCopyResponse —_chmod()
protected
_chmod(string $path[, int $mode = 0777 ]) : void
Parameters
- $path : string
- $mode : int = 0777
Return values
void —_copyBaseThemeFiles()
protected
_copyBaseThemeFiles(IdentifiedThemeInterface $baseTheme, ThemeDirectoryRootInterface $destination) : CustomThemeCopyResponse
Parameters
- $baseTheme : IdentifiedThemeInterface
- $destination : ThemeDirectoryRootInterface
Tags
Return values
CustomThemeCopyResponse —_copyCustomHtmlDirectory()
protected
_copyCustomHtmlDirectory(IdentifiedThemeInterface $theme, $directory, ThemeDirectoryRootInterface $destination) : bool|CustomThemeCopyResponse|mixed
Parameters
- $theme : IdentifiedThemeInterface
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
bool|CustomThemeCopyResponse|mixed —_copyCustomJsDirectory()
protected
_copyCustomJsDirectory(ThemeId $themeId, $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyCustomStylesDirectory()
protected
_copyCustomStylesDirectory(ThemeId $themeId, $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyFile()
protected
_copyFile(string $sourceFile, string $destinationFile) : void
Parameters
- $sourceFile : string
- $destinationFile : string
Return values
void —_copyGxModulesExtensionsForTheme()
protected
_copyGxModulesExtensionsForTheme(string $gxModuleThemeId, ThemeDirectoryRootInterface $destination[, string $group = 'core' ]) : bool|CustomThemeCopyResponse
Parameters
- $gxModuleThemeId : string
- $destination : ThemeDirectoryRootInterface
- $group : string = 'core'
Tags
Return values
bool|CustomThemeCopyResponse —_copyMainThemeDirectory()
protected
_copyMainThemeDirectory(ThemeId $themeId, ThemeDirectoryInterface $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory : ThemeDirectoryInterface
- $destination : ThemeDirectoryRootInterface
Return values
void —_copyMainThemeFile()
protected
_copyMainThemeFile(ThemeId $themeId, ThemeDirectoryInterface $directory, ThemeDirectoryRootInterface $destination, string $file) : void
Parameters
- $themeId : ThemeId
- $directory : ThemeDirectoryInterface
- $destination : ThemeDirectoryRootInterface
- $file : string
Return values
void —_copyOrReplaceFile()
protected
_copyOrReplaceFile(string $sourceFile, $destinationFile) : void
Parameters
Return values
void —_copyOrReplaceThemeFile()
protected
_copyOrReplaceThemeFile(ThemeId $themeId, ThemeDirectoryInterface $directory, ThemeDirectoryRootInterface $destination, string $file) : void
Parameters
- $themeId : ThemeId
- $directory : ThemeDirectoryInterface
- $destination : ThemeDirectoryRootInterface
- $file : string
Return values
void —_copySettingsJson()
protected
_copySettingsJson(VariableThemeDirectoriesInterface|IdentifiedThemeInterface $theme, ThemeDirectoryRootInterface $destination) : void
Parameters
- $theme : VariableThemeDirectoriesInterface|IdentifiedThemeInterface
- $destination : ThemeDirectoryRootInterface
Return values
void —_copyStyleEditThemeDirectory()
protected
_copyStyleEditThemeDirectory(ThemeId $themeId, $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyThemeDirectory()
protected
_copyThemeDirectory(ThemeId $themeId, $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyThemeFontsDirectory()
protected
_copyThemeFontsDirectory(ThemeId $themeId, $directory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $directory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyThemeImagesDirectory()
protected
_copyThemeImagesDirectory(ThemeId $themeId, $imagesDirectory, ThemeDirectoryRootInterface $destination) : void
Parameters
- $themeId : ThemeId
- $imagesDirectory :
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_copyThemeJson()
protected
_copyThemeJson(VariableThemeDirectoriesInterface $theme, ThemeDirectoryRootInterface $destination) : void
Parameters
- $theme : VariableThemeDirectoriesInterface
- $destination : ThemeDirectoryRootInterface
Tags
Return values
void —_duplicateFilesThatHaveNoMatchingMinOrSourceFile()
Creates a duplicate of a file with .min if only the source file exists or a file without .min if only the .min file exists
protected
_duplicateFilesThatHaveNoMatchingMinOrSourceFile(array<string|int, string> $files) : void
Parameters
- $files : array<string|int, string>
Return values
void —_endsWith()
protected
_endsWith( $haystack, $needle) : bool
Parameters
Return values
bool —_extendHtmlFile()
protected
_extendHtmlFile( $sourceFile, $destinationFile, $suffix) : mixed
Parameters
Tags
Return values
mixed —_findFilesThatHaveNoMatchingMinOrSourceFile()
Checks the $themeDirectoryRoot (/public/theme) for files that have no matching source or .min file
protected
_findFilesThatHaveNoMatchingMinOrSourceFile(ThemeDirectoryRootInterface $themeDirectoryRoot) : void
Parameters
- $themeDirectoryRoot : ThemeDirectoryRootInterface
Return values
void —_findScriptsAndSheetsInDirectory()
protected
_findScriptsAndSheetsInDirectory(StringType $directory) : array<string|int, string>
Parameters
- $directory : StringType
Return values
array<string|int, string> —_getRelative()
protected
_getRelative(ThemeDirectoryRootInterface $directory) : mixed
Parameters
- $directory : ThemeDirectoryRootInterface
Return values
mixed —_getRelativeFromDir()
protected
_getRelativeFromDir( $file, string $dir) : string
Parameters
Return values
string —_getRelativeFromFile()
protected
_getRelativeFromFile(ExistingFile $file) : string
Parameters
- $file : ExistingFile
Return values
string —_loadActiveVariants()
protected
_loadActiveVariants(ThemeDirectoryRootInterface $destination) : ConfigurationCollection
Parameters
- $destination : ThemeDirectoryRootInterface
Tags
Return values
ConfigurationCollection —_moveJsFromCustomRootDirectoryToCustomGlobalDirectory()
Modifies the path if a file would be placed inside the root of the custom directory. The file will be moved inside the global directory of system directory
protected
_moveJsFromCustomRootDirectoryToCustomGlobalDirectory(string $path, string $source) : string
This method is only called for child themes
Parameters
- $path : string
- $source : string
Return values
string —mixed
_replaceCustomInPath()
protected
_replaceCustomInPath(string $path) : string
Parameters
- $path : string
Return values
string —_saveMainTheme()
protected
_saveMainTheme(MainThemeInterface $mainTheme, ThemeDirectoryRootInterface $destination) : void
Parameters
- $mainTheme : MainThemeInterface
- $destination : ThemeDirectoryRootInterface
Return values
void —_saveTheme()
protected
_saveTheme(ThemeInterface $theme, ThemeDirectoryRootInterface $destination) : bool|CustomThemeCopyResponse|mixed
Parameters
- $theme : ThemeInterface
- $destination : ThemeDirectoryRootInterface
Tags
Return values
bool|CustomThemeCopyResponse|mixed —_saveThemeStructure()
protected
_saveThemeStructure(MainThemeInterface $mainTheme, ThemeDirectoryRootInterface $destination, ThemeInterface ...$childThemes) : void
Parameters
- $mainTheme : MainThemeInterface
- $destination : ThemeDirectoryRootInterface
- $childThemes : ThemeInterface
Tags
Return values
void —_stringAfter()
protected
_stringAfter( $searchFor, $subject) : bool|string
Parameters
Return values
bool|string —_stringReplaceFirst()
protected
_stringReplaceFirst( $search, $replace, $subject) : string
Parameters
Return values
string —recursiveChmod()
protected
recursiveChmod(string $path[, int $mode = 0777 ]) : void
Parameters
- $path : string
- $mode : int = 0777