class SS_TemplateManifest (View source)

A class which builds a manifest of all templates present in a directory, in both modules and themes.

Constants

TEMPLATES_DIR

Methods

__construct(string $base, string $project, bool $includeTests = false, bool $forceRegen = false)

Constructs a new template manifest. The manifest is not actually built or loaded from cache until needed.

string
getBase()

No description

string
getCacheKey(bool $includeTests = false)

Generate a unique cache key to avoid manifest cache collisions.

array
getTemplates()

Returns a map of all template information. The map is in the following format:

array
getTemplate(string $name)

Returns a set of possible candidate templates that match a certain template name.

array
getCandidateTemplate(string $name, string $theme = null)

Returns the correct candidate template. In order of importance, application project code, current theme and finally modules.

regenerate(bool $cache = true)

Regenerates the manifest by scanning the base path.

handleFile($basename, $pathname, $depth)

No description

Details

__construct(string $base, string $project, bool $includeTests = false, bool $forceRegen = false)

Constructs a new template manifest. The manifest is not actually built or loaded from cache until needed.

Parameters

string $base

The base path.

string $project

Path to application code

bool $includeTests

Include tests in the manifest.

bool $forceRegen

Force the manifest to be regenerated.

string getBase()

Return Value

string

string getCacheKey(bool $includeTests = false)

Generate a unique cache key to avoid manifest cache collisions.

We compartmentalise based on the base path, the given project, and whether or not we intend to include tests.

Parameters

bool $includeTests

Return Value

string

array getTemplates()

Returns a map of all template information. The map is in the following format:

array( 'moduletemplate' => array( 'main' => '/path/to/module/templates/Main.ss' ), 'include' => array( 'include' => '/path/to/module/templates/Includes/Include.ss' ), 'page' => array( 'themes' => array( 'simple' => array( 'main' => '/path/to/theme/Page.ss' 'Layout' => '/path/to/theme/Layout/Page.ss' ) ) ) )

Return Value

array

array getTemplate(string $name)

Returns a set of possible candidate templates that match a certain template name.

This is the same as extracting an individual array element from {@link SS_TemplateManifest::getTemplates()}.

Parameters

string $name

Return Value

array

array getCandidateTemplate(string $name, string $theme = null)

Returns the correct candidate template. In order of importance, application project code, current theme and finally modules.

Parameters

string $name
string $theme
  • theme name

Return Value

array

regenerate(bool $cache = true)

Regenerates the manifest by scanning the base path.

Parameters

bool $cache

handleFile($basename, $pathname, $depth)

Parameters

$basename
$pathname
$depth