Cms\Classes\SnippetManager

Overview

SnippetManager returns information about snippets based on partials and components.


Protected Properties

protected array|null $snippets


Public Methods

public addSnippet()

public addSnippet(Snippet $snippet): void 

addSnippet to the list of snippets

public static clearCache()

public static clearCache(Cms\Classes\Theme $theme): void

clearCache clears front-end run-time cache.

public findByCodeOrComponent()

public findByCodeOrComponent(
    Cms\Classes\Theme $theme,
    string $code,
    string $componentClass,
    boolean $allowCaching = false
): object 

findByCodeOrComponent is used internally by the system.

public getPartialSnippetMap()

public getPartialSnippetMap(Cms\Classes\Theme $theme): array 

getPartialSnippetMap as a list of partial-based snippets and corresponding partial names. Returns an associative array with the snippet code in keys and partial file names in values.

public static instance()

public static instance(): static 

instance creates a new instance of this singleton

public listSnippets()

public listSnippets(Cms\Classes\Theme|null $theme = null): array 

listSnippets returns a list of available snippets. Returns an unsorted array of snippet objects.

public removeSnippet()

public removeSnippet(string $snippetCode): void 

removeSnippet with the given code from the list of snippets

Protected Methods

protected static getPartialMapCacheKey()

protected static getPartialMapCacheKey($theme): void

getPartialMapCacheKey returns a cache key for this record.

protected listComponentSnippets()

protected listComponentSnippets(): array 

listComponentSnippets returns a list of snippets created from components.

protected listThemeSnippets()

protected listThemeSnippets(Cms\Classes\Theme $theme): array 

listThemeSnippets returns a list of snippets in the specified theme.