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
- $implement - extensions for this class. (defined in October\Rain\Extension\Extendable)
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
- $extensionData - contains class reflection information, including behaviors. (defined in October\Rain\Extension\Extendable)
- $extendableStaticMethods - is a collection of static methods used by behaviors. (defined in October\Rain\Extension\Extendable)
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
Inherited Public Methods
- __call() - calls an undefined local method. (defined in October\Rain\Extension\Extendable)
- __callStatic() - calls an undefined static method. (defined in October\Rain\Extension\Extendable)
- __sleep() - prepare the object for serialization. (defined in October\Rain\Extension\Extendable)
- __wakeup() - when a model is being unserialized, check if it needs to be booted. (defined in October\Rain\Extension\Extendable)
- addDynamicMethod() - programmatically adds a method to the extendable class. (defined in October\Rain\Extension\Extendable)
- addDynamicProperty() - programmatically adds a property to the extendable class. (defined in October\Rain\Extension\Extendable)
- asExtension() - is short hand for
getClassExtension()method, except takes the short. (defined in October\Rain\Extension\Extendable) - clearExtendedClasses() - (defined in October\Rain\Extension\Extendable)
- extend() - this class with a closure. (defined in October\Rain\Extension\Extendable)
- extendClassWith() - dynamically extends a class with a specified behavior. (defined in October\Rain\Extension\Extendable)
- extendableCall() - magic method for
__call(). (defined in October\Rain\Extension\Extendable) - extendableCallStatic() - magic method for
__callStatic(). (defined in October\Rain\Extension\Extendable) - extendableConstruct() - should be called as part of the constructor. (defined in October\Rain\Extension\Extendable)
- extendableDestruct() - should be called when serializing the object. (defined in October\Rain\Extension\Extendable)
- extendableExtendCallback() - is a helper method for
::extend()static method. (defined in October\Rain\Extension\Extendable) - extendableGet() - magic method for
__get(). (defined in October\Rain\Extension\Extendable) - extendableSet() - magic method for
__set(). (defined in October\Rain\Extension\Extendable) - getClassExtension() - returns a behavior object from an extendable class, example:. (defined in October\Rain\Extension\Extendable)
- getClassMethodAsReflector() - (defined in October\Rain\Extension\Extendable)
- getClassMethods() - gets a list of class methods, extension equivalent of get_class_methods(). (defined in October\Rain\Extension\Extendable)
- getDynamicProperties() - returns all dynamic properties and their values. (defined in October\Rain\Extension\Extendable)
- implementClassWith() - will implement an extension using non-interference and should. (defined in October\Rain\Extension\Extendable)
- isClassExtendedWith() - checks if extendable class is extended with a behavior object. (defined in October\Rain\Extension\Extendable)
- isClassInstanceOf() - checks if the class implements the supplied interface methods. (defined in October\Rain\Extension\Extendable)
- methodExists() - checks if a method exists, extension equivalent of method_exists(). (defined in October\Rain\Extension\Extendable)
- propertyExists() - checks if a property exists, extension equivalent of
property_exists(). (defined in October\Rain\Extension\Extendable)
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
- extendableIsAccessible() - checks if a property is accessible, property equivalent. (defined in October\Rain\Extension\Extendable)
- extensionExtractImplements() - will return classes to implement. (defined in October\Rain\Extension\Extendable)
- extensionExtractMethods() - extracts the available methods from a behavior and adds it. (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromDynamicMethods() - (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromExtensions() - (defined in October\Rain\Extension\Extendable)