Contents

Tailor\Classes\Blueprint

Overview

Blueprint represents a blueprint file object

Extends

Public Properties

public array $attributes

attributes for the template, taken from the config

public string $fileName

fileName specifies the file name corresponding the Blueprint object

public string $mtime

mtime last modified time

public string $content

content of file

public bool $exists

exists indicates if the model exists.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected string $typeName

typeName of the blueprint

protected string $originalFileName

originalFileName specifies the file name that the template was originally loaded

protected array $allowedExtensions

allowedExtensions for template files

protected static string $defaultDatasource

defaultDatasource is used by unit tests.

protected static array $booted

booted models

protected string $datasource

datasource is the data source for the model, a directory path.

protected string $datasourceTheme

datasourceTheme is the theme directory name, used to filter blueprints.

protected static array|null $resolvedPlugins

protected static array|null $resolvedActiveTheme

protected static array|null $resolvedThemes

Show inherited protected properties

Inherited Protected Properties


Public Methods

public __construct()

public __construct($attributes = []): void

public __get()

public __get($key): void

__get attributes on the model

public __isset()

public __isset($key): void

__isset determines if an attribute exists on the model

public __set()

public __set($key, $value): void

__set attributes on the model

public __unset()

public __unset($key): void

__unset an attribute on the model

public static blessBlueprint()

public static blessBlueprint($blueprint): void

blessBlueprint promotes a blueprint class to its specific type, for example, a global blueprint resolves to the GlobalBlueprint class object, and relevant attributes are transferred to the new object.

public createDirectory()

public createDirectory($newName, $parent): void 

createDirectory creates a directory under a parent path within the blueprints root.

public databaseLayerEnabled()

public databaseLayerEnabled(): bool 

databaseLayerEnabled returns true when DB-layered blueprints should be consulted for this instance. For theme-scoped blueprints the theme's own databaseLayerEnabled() flag is honored; for app and plugin blueprints the global cms.database_templates config governs.

public delete()

public delete(): void

delete template. When the resolved datasource has the database layer enabled, a tombstone row is written and the filesystem is left alone so the deletion propagates across instances even when the on-disk copy cannot be removed.

public deletePaths()

public deletePaths($fileList): void 

deletePaths removes the given list of files or directories under the blueprints root. Directories must be empty.

public find()

public find($fileName): void

find a single template by its file name. When the resolved datasource has the database layer enabled, a matching SourceFile row overrides the filesystem copy and a soft-deleted row acts as a tombstone (the file is reported as missing even when a filesystem copy exists).

public forceSave()

public forceSave(): void

public get()

public get($options = []): array 

get all blueprints and uses simple objects

Available options:

  • recursive: search subfolders and place in 'templates' key
  • flatten: produce a flat array instead of a recursive array
  • filterPath: only include within an inner path
  • filterFiles: only include files
  • filterFolders: only include folders
  • filterEditable: only show editable templates

public getBasePath()

public getBasePath(): string 

getBasePath returns the base path for these objects

public getContentTableName()

public getContentTableName(): string 

public getDatasourceTheme()

public getDatasourceTheme(): void

public getFilePath()

public getFilePath($fileName = null): string 

getFilePath returns the absolute file path of an template

public getJoinTableName()

public getJoinTableName(): string 

public getMessage()

public getMessage($name, $default = null, $vars = []): string 

getMessage looks up a custom message from the blueprint

public getMetaData()

public getMetaData(): array 

getMetaData returns meta data for the content schema table

public getModelClassName()

public getModelClassName(): void

public static getMtimeByName()

public static getMtimeByName($fileName): int|null 

getMtimeByName returns the last modified time using the same resolution order as find, or null when the blueprint is missing or tombstoned.

public getNavigationCodeName()

public getNavigationCodeName(): string 

public getPermissionCodeName()

public getPermissionCodeName($name = null): string 

getPermissionCodeName returns the permission code, which can be customized with the permissions.code blueprint property, also used to share permissions between blueprints

public getPermissionsOption()

public getPermissionsOption($key): void

getPermissionsOption returns an option from the permissions blueprint property

public static getPluginDatasources()

public static getPluginDatasources(): array 

getPluginDatasources returns the blueprint directories provided by plugins, keyed by plugin code.

public getRepeaterTableName()

public getRepeaterTableName(): string 

public getSourceIdentifier()

public getSourceIdentifier(): string 

getSourceIdentifier returns the cms_source_files source identifier for this instance's resolved datasource. Encodes the origin so app, plugin and theme blueprints can coexist in the same table without colliding.

public static hydrate()

public static hydrate($items): Tailor\Classes\BlueprintCollection 

hydrate a collection of templates from plain arrays

public static inDatasource()

public static inDatasource($path, $theme = null): void

inDatasource prepares the datasource for the model.

public static listInProject()

public static listInProject($options = ]): [Tailor\Classes\BlueprintCollection 

listInProject lists all blueprints in a project, loaded in priority order: app, plugins, active theme, then other themes.

public static load()

public static load($fileName): Tailor\Classes\Blueprint|null 

load the object from a file

public move()

public move($selectedList, $destinationDir): void 

move relocates a list of files or directories into a destination directory under the blueprints root.

public newCollection()

public newCollection($templates = ]): [Tailor\Classes\BlueprintCollection 

newCollection instance

public static newFromIndexer()

public static newFromIndexer($attributes = []): void

newFromIndexer creates a new instance from the indexer

public newModelInstance()

public newModelInstance(): void

newModelInstance returns a new instance of the model associated with this blueprint

public rename()

public rename($newName, $originalPath): void 

rename renames a single file or directory within the blueprints root.

public static resetDatasourceCache()

public static resetDatasourceCache(): void 

resetDatasourceCache clears the memoized datasource discovery results, forcing the next listInProject call to resolve plugins and themes again.

public save()

public save($options = null): void

save the object to the disk, or to the cms_source_files table when the resolved datasource has the database layer enabled.

public static setDefaultDatasource()

public static setDefaultDatasource($path): void

public toArray()

public toArray(): array 

toArray converts this instance to an array

public upload()

public upload($uploadedFile, $destinationDir): void 

upload accepts a single uploaded file into a destination directory under the blueprints root.

public validate()

public validate(): void

validate the blueprint

Show inherited public methods

Inherited Public Methods

Protected Methods

protected assertNoDatabaseCollision()

protected assertNoDatabaseCollision(
    $source,
    $basePath,
    $newPath,
    $name = null
): void 

assertNoDatabaseCollision throws when the target path is already occupied by an active row or an unsuppressed filesystem file.

protected static boot()

protected static boot(): void

boot is the "booting" method of the model.

protected bootIfNotBooted()

protected bootIfNotBooted(): void

bootIfNotBooted checks if the model needs to be booted and if so, do it.

protected deletePathsWithDatabase()

protected deletePathsWithDatabase($fileList): void 

deletePathsWithDatabase deletes against the database layer

protected static getActiveThemeCodes()

protected static getActiveThemeCodes(): array 

getActiveThemeCodes returns the active theme code with its parent theme code, if any

protected static getDefaultActiveTheme()

protected static getDefaultActiveTheme(): void

getDefaultActiveTheme returns the active theme and its parent as datasources, where the child theme takes priority over the parent.

protected static getDefaultPlugins()

protected static getDefaultPlugins(): void

protected static getDefaultThemes()

protected static getDefaultThemes(): void

getDefaultThemes returns all non-active themes as datasources

protected getInternal()

protected getInternal($path): array 

getInternal helps the get method. When the resolved datasource has the database layer enabled, results are merged with active SourceFile rows and filesystem entries whose paths are tombstoned in the database are suppressed.

protected getOperationExtensions()

protected getOperationExtensions(): array 

getOperationExtensions returns allowed extensions for upload/rename operations. Blueprints are always YAML.

protected getRelativePath()

protected getRelativePath($path): string 

getRelativePath returns path relative to the theme template directory

protected invalidYamlParse()

protected invalidYamlParse($content): void

protected makeBlueprintTableName()

protected makeBlueprintTableName($type = 'content'): string 

makeBlueprintTableName where type can be used for content, join or repeater

protected moveWithDatabase()

protected moveWithDatabase($selectedList, $destinationDir): void 

moveWithDatabase relocates files and directories against the database layer

protected normalizeOperationPath()

protected normalizeOperationPath($path): string 

normalizeOperationPath produces the canonical relative path used as the SourceFile path key, matching the normalization in Blueprint::getInternal().

protected renameWithDatabase()

protected renameWithDatabase($newName, $originalPath): void 

renameWithDatabase performs a rename against the database layer

protected resolvePluginCodeForDatasource()

protected resolvePluginCodeForDatasource($path): string|null 

resolvePluginCodeForDatasource walks the registered plugin paths to find the one whose blueprints directory matches the given datasource path. Returns null when the datasource is not a plugin path.

protected rewriteRowPathPrefixes()

protected rewriteRowPathPrefixes($oldPrefix, $newPrefix): void 

rewriteRowPathPrefixes moves every row, including tombstones, from the old directory prefix to the new one.

protected saveToDatabase()

protected saveToDatabase($fileName): void 

saveToDatabase upserts the current content into a SourceFile row for this blueprint's resolved datasource. When the filename has changed, the old path is tombstoned so the rename propagates across instances.

protected static themeHasDbBlueprints()

protected static themeHasDbBlueprints($themeCode): bool 

themeHasDbBlueprints returns true when the theme has its database layer enabled and active SourceFile rows exist for its blueprint source.

protected validateFileName()

protected validateFileName(string $fileName = null): void 

validateFileName extension and path.

protected validateOperationFileExtension()

protected validateOperationFileExtension($name, $allowedExtensions): bool 

validateOperationFileExtension checks a filename against the allowed extension list.

protected validateOperationName()

protected validateOperationName($name): bool 

validateOperationName ensures a single file or directory name contains only safe characters.

protected validateOperationPath()

protected validateOperationPath($path): bool 

validateOperationPath ensures a relative path does not escape the blueprints root or contain unsafe characters.

Show inherited protected methods

Inherited Protected Methods