Cms\Classes\Lang
Overview
Lang represents CMS language files
Extends
Public Properties
public string $fileName
fileName specifies the file name corresponding the CMS object
public string $mtime
Last modified time.
public string $content
The entire file content.
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 Cms\Classes\Theme $theme
A reference to the CMS theme containing the object.
protected string $dirName
dirName for the container name inside the theme
protected string $originalFileName
Specifies the file name, the CMS object was loaded from.
protected array $fillable
fillable attributes that are mass assignable
protected array $allowedExtensions
allowedExtensions for language files
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($theme): void
__construct creates an instance of the object and associates it with a CMS theme
public delete()
public delete(): void
delete the object from disk, or write a tombstone row when the theme has the database layer enabled. A tombstone suppresses the filesystem copy from listing/find, so the file appears deleted across all instances even when the filesystem still has it.
public fill()
public fill(array $attributes): void
Sets the object attributes.
public find()
public find($fileName): void
find a single template by its file name, resolving against the theme's database layer and filesystem before falling back to its parent theme.
public get()
public get($options = []): array
get all language files in a theme
Available options:
- filterFiles: only include files
public static getDefaultKeys()
public static getDefaultKeys($theme, $excludeFileName = null): array|null
getDefaultKeys returns the translation keys from the primary site's language file, trying the full locale (e.g. en-au.json) then the base language (e.g. en.json) as a fallback.
public getFileName()
public getFileName(): string
public getFilePath()
public getFilePath($fileName = null): string
getFilePath returns the absolute file path of a lang file
public getTheme()
public getTheme(): Cms\Classes\Theme
getTheme returns the theme this lang file belongs to.
public static inTheme()
public static inTheme($theme): Cms\Classes\Lang
inTheme prepares the theme datasource for the model.
public static listInTheme()
public static listInTheme($theme, $options = []): void
public static load()
public static load(Cms\Classes\Theme $theme, string $fileName): mixed
load the object from a file
public save()
public save($options = []): void
save the object to the disk, or to the database when the theme has the database layer enabled.
public validate()
public validate(): void
validate object
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)
- __get() - an undefined property. (defined in October\Rain\Extension\Extendable)
- __set() - an undefined property. (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 findInTheme()
protected findInTheme($theme, $fileName): void
findInTheme resolves a lang file against a single theme, checking its database layer first and falling back to its filesystem copy.
protected findSourceFile()
protected findSourceFile($theme, $fileName): Cms\Models\SourceFile|null
findSourceFile returns an active SourceFile row for the given theme and filename, or null if none exists.
protected getInternal()
protected getInternal($path, $theme): array
getInternal helps the get method. When the theme has the database layer enabled, results are merged with active SourceFile rows and any filesystem entries whose paths are tombstoned in the database are suppressed.
protected getRelativePath()
protected getRelativePath($path, $theme): string
getRelativePath returns path relative to the theme lang directory
protected getSourceIdentifier()
protected getSourceIdentifier($theme): string
getSourceIdentifier returns the SourceFile source identifier for the given theme's lang files. Format: theme.{themeDir}.lang
protected hydrateFromSourceFile()
protected hydrateFromSourceFile($fileName, $row): static
hydrateFromSourceFile populates this instance from a SourceFile row, using the row's updated_at as the mtime so concurrent-edit detection compares like for like.
protected isTombstoned()
protected isTombstoned($theme, $fileName): bool
isTombstoned returns true if a soft-deleted SourceFile row exists for the given theme and filename, meaning the file should be reported as not existing even when the filesystem still has a copy.
protected saveToDatabase()
protected saveToDatabase(): void
saveToDatabase upserts the current content into a SourceFile row for this theme and filename
protected validateFileName()
protected validateFileName($fileName = null): void
validateFileName supplied with extension and path.
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)