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

Properties

protected $base
protected $tests
protected $cache
protected $cacheKey
protected $project
protected $inited
protected $templates

Methods

public
__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.

public
string
getBase()

No description

public
string
getCacheKey(bool $includeTests = false)

Generate a unique cache key to avoid manifest cache collisions.

public
array
getTemplates()

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

public
array
getTemplate(string $name)

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

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

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

public
regenerate(bool $cache = true)

Regenerates the manifest by scanning the base path.

public
handleFile($basename, $pathname, $depth)

No description

protected
init()

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()

No description

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 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)

No description

Parameters

$basename
$pathname
$depth

protected init()

No description