PHP Class RainLab\Pages\Classes\Snippet

Author: Alexey Bobkov, Samuel Georges
Mostra file Open project: rainlab/pages-plugin Class Usage Examples

Public Properties

Property Type Description
$code Specifies the snippet code.

Protected Properties

Property Type Description
$componentClass Snippet component class name.
$componentObj Snippet component object.
$description Specifies the snippet description.
$name Specifies the snippet name.
$pageSnippetMap Internal cache of snippet declarations defined on a page.
$properties Snippet properties.

Public Methods

Method Description
__construct ( )
clearMapCache ( Cms\Classes\Theme $theme ) Clears the snippet map item cache
extendPartialForm ( $formWidget ) Extends the partial form with Snippet fields.
getComponentClass ( ) : string Returns the snippet component class name.
getDescription ( ) : string Returns the snippet description.
getName ( ) : string Returns the snippet name.
getProperties ( ) Returns the snippet property list as array, in format compatible with Inspector.
initFromComponentInfo ( string $componentClass, string $componentCode ) Initializes the snippet from a CMS component information.
initFromPartial ( $partial ) Initializes the snippet from a CMS partial.
listPageComponents ( string $pageName, Cms\Classes\Theme $theme, $markup ) : array Returns a list of component definitions declared on the page.
processPageMarkup ( string $pageName, Cms\Classes\Theme $theme, string $markup ) : string Parses the static page markup and renders snippets defined on the page.
processTemplateSettings ( $template )
processTemplateSettingsArray ( $settingsArray )

Protected Methods

Method Description
dropDownOptionsToArray ( $optionsString )
dropDownOptionsToString ( $optionsArray )
extractSnippetsFromMarkup ( $markup, $theme )
extractSnippetsFromMarkupCached ( $theme, $pageName, $markup )
getComponent ( ) : Cms\Classes\ComponentBase Returns a component corresponding to the snippet.
getMapCacheKey ( $theme ) Returns a cache key for this record.
parseIniProperties ( $properties ) : array Converts a keyed object to an array, converting the index to the "property" value.
preprocessPropertyValues ( $theme, $snippetCode, $componentClass, $properties ) Apples default property values and fixes property names.

Method Details

__construct() public method

public __construct ( )

clearMapCache() public static method

Clears the snippet map item cache
public static clearMapCache ( Cms\Classes\Theme $theme )
$theme Cms\Classes\Theme Specifies the current theme.

dropDownOptionsToArray() protected static method

protected static dropDownOptionsToArray ( $optionsString )

dropDownOptionsToString() protected static method

protected static dropDownOptionsToString ( $optionsArray )

extendPartialForm() public static method

Extends the partial form with Snippet fields.
public static extendPartialForm ( $formWidget )

extractSnippetsFromMarkup() protected static method

protected static extractSnippetsFromMarkup ( $markup, $theme )

extractSnippetsFromMarkupCached() protected static method

protected static extractSnippetsFromMarkupCached ( $theme, $pageName, $markup )

getComponent() protected method

This method should not be used in the front-end request handling code.
protected getComponent ( ) : Cms\Classes\ComponentBase
return Cms\Classes\ComponentBase

getComponentClass() public method

If the snippet is a partial snippet, returns NULL.
public getComponentClass ( ) : string
return string Returns the snippet component class name

getDescription() public method

This method should not be used in the front-end request handling.
public getDescription ( ) : string
return string

getMapCacheKey() protected static method

Returns a cache key for this record.
protected static getMapCacheKey ( $theme )

getName() public method

This method should not be used in the front-end request handling.
public getName ( ) : string
return string

getProperties() public method

Returns the snippet property list as array, in format compatible with Inspector.
public getProperties ( )

initFromComponentInfo() public method

Initializes the snippet from a CMS component information.
public initFromComponentInfo ( string $componentClass, string $componentCode )
$componentClass string Specifies the component class.
$componentCode string Specifies the component code.

initFromPartial() public method

Initializes the snippet from a CMS partial.
public initFromPartial ( $partial )

listPageComponents() public static method

Returns a list of component definitions declared on the page.
public static listPageComponents ( string $pageName, Cms\Classes\Theme $theme, $markup ) : array
$pageName string Specifies the static page file name (the name of the corresponding content block file).
$theme Cms\Classes\Theme Specifies a parent theme.
return array Returns an array of component definitions

parseIniProperties() protected static method

Converts a keyed object to an array, converting the index to the "property" value.
protected static parseIniProperties ( $properties ) : array
return array

preprocessPropertyValues() protected static method

As snippet properties are defined with data attributes, they are lower case, whereas real property names are case sensitive. This method finds original property names defined in snippet classes or partials and replaces property names defined in the static page markup.
protected static preprocessPropertyValues ( $theme, $snippetCode, $componentClass, $properties )

processPageMarkup() public static method

Parses the static page markup and renders snippets defined on the page.
public static processPageMarkup ( string $pageName, Cms\Classes\Theme $theme, string $markup ) : string
$pageName string Specifies the static page file name (the name of the corresponding content block file).
$theme Cms\Classes\Theme Specifies a parent theme.
$markup string Specifies the markup string to process.
return string Returns the processed string.

processTemplateSettings() public static method

public static processTemplateSettings ( $template )

processTemplateSettingsArray() public static method

public static processTemplateSettingsArray ( $settingsArray )

Property Details

$code public_oe property

Specifies the snippet code.
public $code

$componentClass protected_oe property

Snippet component class name.
protected $componentClass

$componentObj protected_oe property

Snippet component object.
protected $componentObj

$description protected_oe property

Specifies the snippet description.
protected $description

$name protected_oe property

Specifies the snippet name.
protected $name

$pageSnippetMap protected_oe static_oe property

Internal cache of snippet declarations defined on a page.
protected static $pageSnippetMap

$properties protected_oe property

Snippet properties.
protected $properties