ThemePlugin
extends Plugin
in package
implements
ThemeInterface
Uses
ArrayableTrait
Base class for all themes
Interfaces, Classes and Traits
- ThemeInterface
- A theme is a regular plugin, it defines regions and can extend another theme.
Table of Contents
- DEFINE_SCSS_COMPILER = 'define_scss_compiler'
- $_compiler : Compiler
- $_preferences : ThemePreferencesInterface
- $_regions : array<string|int, mixed>
- $assetBundles : array<string|int, mixed>
- Bundle assets defined by this theme, keyed by the url path. '*' for all paths, '' for homepage. Wrap key with // for regular expression : [ '*' => [ CommonAssets::class ], '' => [ HomeAssets::class ], 'blog' => [ BlogAsset::class ] ]
- $inheritsAssetBundles : bool
- Should the parent asset bundle be registered as well
- $inheritsAssets : bool
- Should this theme inherits parent's assets
- $templatesPaths : array<string|int, string>
- array of all the template paths (including those of the parents)
- afterSet() : mixed
- Callback after the theme has been set for a request
- afterThemeInstall() : mixed
- Callback after the plugin is installed, this is only called for pro version.
- afterThemeUninstall() : mixed
- Callback after the plugin is uninstalled.
- fields() : mixed
- getAssetUrl() : string
- Get an url for an theme asset.
- getExtends() : string|null
- Which other theme does this extends from.
- getHasPreview() : bool
- Does this theme have a preview image
- getParent() : ThemeInterface|null
- Get theme parent
- getPreferences() : ThemePreferencesInterface
- Get theme preferences
- getPreviewImage() : string
- Preview image for the theme, returns a web url
- getRegions() : array<string|int, mixed>
- Get theme's regions definitions
- getRegionsTemplate() : string
- Get the base template for rendering regions
- getScssCompiler() : Compiler
- Get the scss compiler.
- getTemplatePaths() : array<string|int, string>
- Absolute template paths, including those of the parent(s)
- getTemplatesFolder() : string
- Folder where the templates are stored for this theme
- isPartial() : bool
- Is this theme partial.
- registerAssetBundles() : mixed
- Register this theme's assets in view for a specific path
- beforeInstall() : bool
- Make sure themes plugin is installed before installing
- defineRegions() : array<string|int, mixed>|null
- Define regions as array
- getAssetBundles() : array<string|int, string>
- Get bundle assets for a url path
- getPreferencesModel() : ThemePreferencesInterface
- Get theme preferences model
- getPreviewImagePath() : string|null
- Get the path of the image preview file
- getScssCompilerOptions() : array<string|int, mixed>
- Get scss compiler default options
- getScssCompilerPlugins() : array<string|int, mixed>
- Get the plugins for the scss compiler
Constants
DEFINE_SCSS_COMPILER
public
mixed
DEFINE_SCSS_COMPILER
= 'define_scss_compiler'
Properties
$_compiler
protected
Compiler
$_compiler
$_preferences
protected
ThemePreferencesInterface
$_preferences
$_regions
protected
array<string|int, mixed>
$_regions
$assetBundles
Bundle assets defined by this theme, keyed by the url path. '*' for all paths, '' for homepage. Wrap key with // for regular expression : [ '*' => [ CommonAssets::class ], '' => [ HomeAssets::class ], 'blog' => [ BlogAsset::class ] ]
protected
array<string|int, mixed>
$assetBundles
= []
$inheritsAssetBundles
Should the parent asset bundle be registered as well
protected
bool
$inheritsAssetBundles
= true
$inheritsAssets
Should this theme inherits parent's assets
protected
bool
$inheritsAssets
= true
$templatesPaths
array of all the template paths (including those of the parents)
protected
array<string|int, string>
$templatesPaths
Methods
afterSet()
Callback after the theme has been set for a request
public
afterSet() : mixed
Tags
Return values
mixed —afterThemeInstall()
Callback after the plugin is installed, this is only called for pro version.
public
afterThemeInstall() : mixed
Tags
Return values
mixed —afterThemeUninstall()
Callback after the plugin is uninstalled.
public
afterThemeUninstall() : mixed
Tags
Return values
mixed —fields()
public
fields() : mixed
Tags
Return values
mixed —getAssetUrl()
Get an url for an theme asset.
public
getAssetUrl(string $path) : string
Parameters
- $path : string
Tags
Return values
string —getExtends()
Which other theme does this extends from.
public
getExtends() : string|null
Tags
Return values
string|null —getHasPreview()
Does this theme have a preview image
public
getHasPreview() : bool
Tags
Return values
bool —getParent()
Get theme parent
public
getParent() : ThemeInterface|null
Tags
Return values
ThemeInterface|null —getPreferences()
Get theme preferences
public
getPreferences() : ThemePreferencesInterface
Tags
Return values
ThemePreferencesInterface —getPreviewImage()
Preview image for the theme, returns a web url
public
getPreviewImage() : string
Tags
Return values
string —getRegions()
Get theme's regions definitions
public
getRegions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getRegionsTemplate()
Get the base template for rendering regions
public
getRegionsTemplate() : string
Tags
Return values
string —getScssCompiler()
Get the scss compiler.
public
getScssCompiler([array<string|int, mixed> $options = [] ]) : Compiler
Parameters
- $options : array<string|int, mixed> = []
-
Override compiler options here. Import paths will be prepended, aliases will be overridden
Tags
Return values
Compiler —getTemplatePaths()
Absolute template paths, including those of the parent(s)
public
getTemplatePaths() : array<string|int, string>
Tags
Return values
array<string|int, string> —getTemplatesFolder()
Folder where the templates are stored for this theme
public
getTemplatesFolder() : string
Tags
Return values
string —isPartial()
Is this theme partial.
public
isPartial() : bool
Tags
Return values
bool —registerAssetBundles()
Register this theme's assets in view for a specific path
public
registerAssetBundles(string $urlPath) : mixed
Parameters
- $urlPath : string
Tags
Return values
mixed —beforeInstall()
Make sure themes plugin is installed before installing
protected
beforeInstall() : bool
Tags
Return values
bool —defineRegions()
Define regions as array
protected
defineRegions() : array<string|int, mixed>|null
[ [ 'handle' => 'region-handle', 'name' => 'Region', 'width' => '100%' //Used in backend blocks section ] ]
Returning null will load parent's theme regions
Return values
array<string|int, mixed>|null —getAssetBundles()
Get bundle assets for a url path
protected
getAssetBundles(string $urlPath) : array<string|int, string>
Parameters
- $urlPath : string
Return values
array<string|int, string> —getPreferencesModel()
Get theme preferences model
protected
getPreferencesModel() : ThemePreferencesInterface
Return values
ThemePreferencesInterface —getPreviewImagePath()
Get the path of the image preview file
protected
getPreviewImagePath() : string|null
Return values
string|null —getScssCompilerOptions()
Get scss compiler default options
protected
getScssCompilerOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getScssCompilerPlugins()
Get the plugins for the scss compiler
protected
getScssCompilerPlugins() : array<string|int, mixed>