Cms\Classes\ThemeManager
Protected Properties
protected array $themes
themes is for storing themes cache
protected array $installedThemes
installedThemes is for storing installed themes cache
protected array $installedThemeDirs
installedThemeDirs is for storing installed themes cache
protected array $bootedThemes
bootedThemes is for storing themes that have been booted
Public Methods
public bootAll()
public bootAll(): void
bootAll will boot language messages for the active theme as theme.acme::lang.*
if it is in the backend
public static clearDatabaseLangCache()
public static clearDatabaseLangCache($source): void
clearDatabaseLangCache forgets stored lang lines for a source. Called when a lang row is saved, tombstoned, or purged.
public createChildTheme()
public createChildTheme($dirName, $newDirName = null): bool
createChildTheme will create a child theme
public deleteTheme()
public deleteTheme($theme): void
deleteTheme completely delete a theme from the system
public duplicateTheme()
public duplicateTheme($dirName, $newDirName = null): bool
duplicateTheme duplicates a theme
public findByIdentifier()
public findByIdentifier($dirName): Cms\Classes\Theme|null
findByIdentifier returns a theme object from a directory name
public findDirectoryName()
public findDirectoryName($code): string|null
findDirectoryName from a code
public findInstalledCode()
public findInstalledCode($dirName): string|null
findInstalledCode returns an installed theme's code from it's dirname
public findLockableThemes()
public findLockableThemes(): array
findLockableThemes returns themes that are installed via composer
public findMissingDependencies()
public findMissingDependencies(): array
findMissingDependencies scans the system plugins to locate any dependencies that are not currently installed. Returns an array of plugin codes that are needed.
ThemeManager::instance()->findMissingDependencies();
public getActiveTheme()
public getActiveTheme(): Cms\Classes\Theme
getActiveTheme return the active theme without affecting the internal cache since it may fire before the session driver has loaded.
public getComposerCode()
public getComposerCode($dirName): string
getComposerCode finds the composer code for a theme author/sometheme-theme
public static getDatabaseLangCacheKey()
public static getDatabaseLangCacheKey($source): string
getDatabaseLangCacheKey returns the cache key for a lang source
public getInstalled()
public getInstalled(): array
getInstalled returns a collection of themes installed
['RainLab.Vanilla' => '1.0.0', ...]
public getLatestVersion()
public getLatestVersion($dirName): string
getLatestVersion finds the latest version for a theme
public getProductCode()
public getProductCode($dirName): string
getProductCode finds the product code for a theme, it relies on the composer file as the source of truth author.sometheme
public getThemePath()
public getThemePath($dirName): string
getThemePath returns the disk path for the theme
public getThemePaths()
public getThemePaths(): array
getThemePaths returns an array of themes and their paths.
public getThemes()
public getThemes(): array
getThemes returns all themes in the filesystem
public getVersionHistory()
public getVersionHistory($dirName): array
getVersionHistory returns the version history for a theme
public importDatabaseAssets()
public importDatabaseAssets($dirName, $srcDirName = null): void
importDatabaseAssets copies asset SourceFile rows for a theme onto the filesystem, mirroring the importDatabaseLangs behavior
public importDatabaseBlueprints()
public importDatabaseBlueprints($dirName, $srcDirName = null): void
importDatabaseBlueprints copies blueprint SourceFile rows back to the filesystem for every blueprint datasource (app, plugins, and the named theme)
public importDatabaseLangs()
public importDatabaseLangs($dirName, $srcDirName = null): void
importDatabaseLangs copies lang SourceFile rows for a theme onto the filesystem, mirroring the importDatabaseTemplates behavior
public importDatabaseTemplates()
public importDatabaseTemplates($dirName, $srcDirName = null): void
public static instance()
public static instance(): static
instance creates a new instance of this singleton
public isInstalled()
public isInstalled($name): bool
isInstalled checks if a theme has ever been installed
public performLockOnTheme()
public performLockOnTheme($dirName): bool
performLockOnTheme will add a lock file on a theme Returns true if the process was successful
public performUnlockOnTheme()
public performUnlockOnTheme($dirName): bool
performUnlockOnTheme will remove the lock file on a theme Returns true if the process was successful
public purgeDatabaseAssets()
public purgeDatabaseAssets($dirName): void
purgeDatabaseAssets removes every asset SourceFile row for a theme, including tombstones
public purgeDatabaseBlueprints()
public purgeDatabaseBlueprints($dirName): void
purgeDatabaseBlueprints removes blueprint SourceFile rows for every blueprint datasource, including tombstones
public purgeDatabaseLangs()
public purgeDatabaseLangs($dirName): void
purgeDatabaseLangs removes every lang SourceFile row for a theme, including tombstones
public purgeDatabaseTemplates()
public purgeDatabaseTemplates($dirName): void
Protected Methods
protected bootTheme()
protected bootTheme($theme, $isBackend = false): void
bootTheme boots a theme if it hasn't been booted already
protected getInstalledDirectories()
protected getInstalledDirectories(): array
getInstalled returns a collection of themes installed and their directories
['rainlab.vanilla' => 'vanilla', ...]
protected importBlueprintSource()
protected importBlueprintSource($source, $targetDir): void
importBlueprintSource writes every active row for the given source to its corresponding path under $targetDir, and deletes the filesystem file for every tombstoned row. Shared between the app, plugin and theme blueprint import paths.
protected injectDatabaseLangLines()
protected injectDatabaseLangLines($theme): void
injectDatabaseLangLines registers any DB-backed lang strings for the theme directly with the translator
protected loadDatabaseLangLines()
protected loadDatabaseLangLines($source): array
loadDatabaseLangLines returns locale lines for a lang source, using the application cache when a previous request already loaded them