Cms\Classes\CmsObject
Overview
This is a base class for all CMS objects - content files, pages, partials and layouts. The class implements basic operations with file-based templates.
Extends
Implements
- ArrayAccess
- Illuminate\Contracts\Support\Arrayable
- Illuminate\Contracts\Support\Jsonable
- JsonSerializable
- Stringable
- Cms\Contracts\CmsObject
Public Properties
public array $rules
The rules to be applied to the data.
public array $attributeNames
The array of custom attribute names.
public array $customMessages
The array of custom error messages.
Show inherited public properties
Inherited Public Properties
- $attributes - saved to the settings area. (defined in October\Rain\Halcyon\Model)
- $exists - indicates if the model exists. (defined in October\Rain\Halcyon\Model)
- $implement - extensions for this class. (defined in October\Rain\Extension\Extendable)
Protected Properties
protected array $fillable
The attributes that are mass assignable.
protected bool $isCompoundObject
Model supports code and settings sections.
protected Cms\Classes\Theme $themeCache
A reference to the CMS theme containing the object.
protected Illuminate\Support\MessageBag $validationErrors
validationErrors message bag
protected static Illuminate\Validation\Validator $validator
validator instance
Show inherited protected properties
Inherited Protected Properties
- $datasource - is the data source for the model, a directory path. (defined in October\Rain\Halcyon\Model)
- $dirName - is the container name associated with the model, eg: pages. (defined in October\Rain\Halcyon\Model)
- $original - attributes. (defined in October\Rain\Halcyon\Model)
- $appends - to the model's array form. (defined in October\Rain\Halcyon\Model)
- $purgeable - List of attribute names which are not considered "settings". (defined in October\Rain\Halcyon\Model)
- $allowedExtensions - is allowable file extensions. (defined in October\Rain\Halcyon\Model)
- $defaultExtension - is default file extension. (defined in October\Rain\Halcyon\Model)
- $wrapCode - section in PHP tags. (defined in October\Rain\Halcyon\Model)
- $maxNesting - is the maximum allowed path nesting level. (defined in October\Rain\Halcyon\Model)
- $loadedFromCache - indicates whether the object was loaded from the cache. (defined in October\Rain\Halcyon\Model)
- $cache - manager. (defined in October\Rain\Halcyon\Model)
- $resolver - instance. (defined in October\Rain\Halcyon\Model)
- $mutatorCache - for each class. (defined in October\Rain\Halcyon\Model)
- $booted - models. (defined in October\Rain\Halcyon\Model)
- $traitInitializers - that will be called on each new instance. (defined in October\Rain\Halcyon\Model)
- $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)
- $emitterSingleEventCollection - of events to be fired once only. (defined in October\Rain\Halcyon\Model)
- $emitterEventCollection - of all registered events. (defined in October\Rain\Halcyon\Model)
- $emitterEventSorted - collection. (defined in October\Rain\Halcyon\Model)
- $eventsBooted - is the array of models booted events. (defined in October\Rain\Halcyon\Model)
- $dispatcher - instance. (defined in October\Rain\Halcyon\Model)
- $observables - are user exposed observable events. (defined in October\Rain\Halcyon\Model)
Public Methods
public static bootValidation()
public static bootValidation(): void
bootValidation trait for this model.
public errors()
public errors(): Illuminate\Support\MessageBag
errors gets validation error message collection for the Model
public forceSave()
public forceSave($options = null): bool
forceSave the model even if validation fails.
public getBaseFileName()
public getBaseFileName(): string
Returns the file name without the extension.
public getContent()
public getContent(): string
Returns the file content.
public getFileName()
public getFileName(): string
Returns the file name.
public getFilePath()
public getFilePath(string $fileName = null): string
Returns the full path to the template file corresponding to this object.
public getId()
public getId(): string
Helper for {{ page.id }} or {{ layout.id }} twig vars Returns a unique string for this object.
public static getModelValidator()
public static getModelValidator(): Illuminate\Validation\Validator
getModelValidator instance.
public getThemeAttribute()
public getThemeAttribute(): Cms\Classes\Theme
Returns the CMS theme this object belongs to.
public getTwigCacheKey()
public getTwigCacheKey(): string
Returns the key used by the Twig cache.
public getTwigContent()
public getTwigContent(): string
Returns the Twig content string.
public static inTheme()
public static inTheme(Cms\Classes\Theme $theme): $this
inTheme prepares the theme datasource for the model.
public isAttributeRequired()
public isAttributeRequired(string $attribute): bool
isAttributeRequired determines if an attribute is required based on the validation rules.
public static listInTheme()
public static listInTheme(
Cms\Classes\Theme $theme,
boolean $skipCache = false
): Collection
listInTheme returns the list of objects in the specified theme. This method is used internally by the system.
public static load()
public static load(mixed $theme, string $fileName): mixed
load the object from a file. This method is used in the CMS back-end. It doesn't use any caching.
public static loadCached()
public static loadCached(
Cms\Classes\Theme $theme,
string $fileName
): mixed
loadCached loads the object from a cache This method is used by the CMS in the runtime. If the cache is not found, it is created.
public save()
public save(array $options = null): bool
save the object to the theme.
public static setModelValidator()
public static setModelValidator(
Illuminate\Validation\Validator $validator
): void
setModelValidator instance.
public static unsetModelValidator()
public static unsetModelValidator(): void
unsetModelValidator for models.
public validate()
public validate(
$rules = null,
$customMessages = null,
$attributeNames = null
): bool
validate the model instance
public static validated()
public static validated(Closure|string $callback): void
validated creates a new native event for handling afterValidate().
public static validating()
public static validating(Closure|string $callback): void
validating creates a new native event for handling beforeValidate().
Inherited Public Methods
- __call() - handles dynamic method calls into the model. (defined in October\Rain\Halcyon\Model)
- __callStatic() - handles dynamic static method calls into the method. (defined in October\Rain\Halcyon\Model)
- __construct() - a new Halcyon model instance. (defined in October\Rain\Halcyon\Model)
- __get() - dynamically retrieve attributes on the model. (defined in October\Rain\Halcyon\Model)
- __isset() - determines if an attribute exists on the model. (defined in October\Rain\Halcyon\Model)
- __set() - dynamically set attributes on the model. (defined in October\Rain\Halcyon\Model)
- __sleep() - prepare the object for serialization. (defined in October\Rain\Halcyon\Model)
- __toString() - converts the model to its string representation. (defined in October\Rain\Halcyon\Model)
- __unset() - an attribute on the model. (defined in October\Rain\Halcyon\Model)
- __wakeup() - when a model is being unserialized, check if it needs to be booted. (defined in October\Rain\Halcyon\Model)
- 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)
- addFillable() - adds fillable attributes for the model. (defined in October\Rain\Halcyon\Model)
- addObservableEvents() - name. (defined in October\Rain\Halcyon\Model)
- addPurgeable() - adds an attribute to the purgeable attributes list. (defined in October\Rain\Halcyon\Model)
- all() - of the models from the datasource. (defined in October\Rain\Halcyon\Model)
- asExtension() - is short hand for
getClassExtension()method, except takes the short. (defined in October\Rain\Extension\Extendable) - attributesToArray() - converts the model's attributes to an array. (defined in October\Rain\Halcyon\Model)
- bindEvent() - creates a new event binding. (defined in October\Rain\Halcyon\Model)
- bindEventOnce() - creates a new event binding that fires once only. (defined in October\Rain\Halcyon\Model)
- cacheMutatedAttributes() - extracts and cache all the mutated attributes of a class. (defined in October\Rain\Halcyon\Model)
- clearBootedModels() - clears the list of booted models so they will be re-booted. (defined in October\Rain\Halcyon\Model)
- clearExtendedClasses() - (defined in October\Rain\Extension\Extendable)
- create() - saves a new model and return the instance. (defined in October\Rain\Halcyon\Model)
- created() - Register a created model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- creating() - Register a creating model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- delete() - the model from the database. (defined in October\Rain\Halcyon\Model)
- deleted() - Register a deleted model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- deleting() - Register a deleting model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- 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) - fetched() - Create a new native event for handling afterFetch(). (defined in October\Rain\Halcyon\Model)
- fetching() - Create a new native event for handling beforeFetch(). (defined in October\Rain\Halcyon\Model)
- fill() - the model with an array of attributes. (defined in October\Rain\Halcyon\Model)
- fireEvent() - and call the listeners. (defined in October\Rain\Halcyon\Model)
- flushEventListeners() - removes all of the event listeners for the model. (defined in October\Rain\Halcyon\Model)
- getAllowedExtensions() - returns the allowable file extensions supported by this model. (defined in October\Rain\Halcyon\Model)
- getAttribute() - gets a plain attribute. (defined in October\Rain\Halcyon\Model)
- getAttributes() - gets all of the current attributes on the model. (defined in October\Rain\Halcyon\Model)
- getBaseFileNameAttribute() - returns the file name without the extension. (defined in October\Rain\Halcyon\Model)
- getCacheManager() - instance. (defined in October\Rain\Halcyon\Model)
- 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)
- getDatasource() - for the model. (defined in October\Rain\Halcyon\Model)
- getDatasourceName() - for the model. (defined in October\Rain\Halcyon\Model)
- getDatasourceResolver() - instance. (defined in October\Rain\Halcyon\Model)
- getDirty() - get the attributes that have been changed since last sync. (defined in October\Rain\Halcyon\Model)
- getDynamicProperties() - returns all dynamic properties and their values. (defined in October\Rain\Extension\Extendable)
- getEventDispatcher() - instance. (defined in October\Rain\Halcyon\Model)
- getFileNameParts() - returns the base file name and extension. (defined in October\Rain\Halcyon\Model)
- getIdAttribute() - is a helper for {{ page.id }} or {{ layout.id }} twig vars. (defined in October\Rain\Halcyon\Model)
- getMaxNesting() - returns the maximum directory nesting allowed by this template. (defined in October\Rain\Halcyon\Model)
- getMutatedAttributes() - gets the mutated attributes for a given instance. (defined in October\Rain\Halcyon\Model)
- getObjectTypeDirName() - returns the directory name corresponding to the object type. (defined in October\Rain\Halcyon\Model)
- getObservableEvents() - names. (defined in October\Rain\Halcyon\Model)
- getOriginal() - gets the model's original attribute values. (defined in October\Rain\Halcyon\Model)
- getSettingsAttribute() - is the settings is attribute contains everything that should. (defined in October\Rain\Halcyon\Model)
- getWrapCode() - returns true if the code section will be wrapped in PHP tags. (defined in October\Rain\Halcyon\Model)
- hasGetMutator() - determines if a get mutator exists for an attribute. (defined in October\Rain\Halcyon\Model)
- hasSetMutator() - determines if a set mutator exists for an attribute. (defined in October\Rain\Halcyon\Model)
- hydrate() - creates a collection of models from plain arrays. (defined in October\Rain\Halcyon\Model)
- implementClassWith() - will implement an extension using non-interference and should. (defined in October\Rain\Extension\Extendable)
- initCacheItem() - initializes the object properties from the cached data. The extra data. (defined in October\Rain\Halcyon\Model)
- 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)
- isCompoundObject() - returns true if this template supports code and settings sections. (defined in October\Rain\Halcyon\Model)
- isDirty() - determines if the model or given attribute(s) have been modified. (defined in October\Rain\Halcyon\Model)
- isFillable() - determines if the given attribute may be mass assigned. (defined in October\Rain\Halcyon\Model)
- isLoadedFromCache() - returns true if the object was loaded from the cache. (defined in October\Rain\Halcyon\Model)
- jsonSerialize() - converts the object into something JSON serializable. (defined in October\Rain\Halcyon\Model)
- methodExists() - checks if a method exists, extension equivalent of method_exists(). (defined in October\Rain\Extension\Extendable)
- newCollection() - Create a new Halcyon Collection instance. (defined in October\Rain\Halcyon\Model)
- newFromBuilder() - creates a new model instance that is existing. (defined in October\Rain\Halcyon\Model)
- newInstance() - creates a new instance of the given model. (defined in October\Rain\Halcyon\Model)
- newQuery() - Get a new query builder for the object. (defined in October\Rain\Halcyon\Model)
- offsetExists() - determines if the given attribute exists. (defined in October\Rain\Halcyon\Model)
- offsetGet() - the value for a given offset. (defined in October\Rain\Halcyon\Model)
- offsetSet() - the value for a given offset. (defined in October\Rain\Halcyon\Model)
- offsetUnset() - the value for a given offset. (defined in October\Rain\Halcyon\Model)
- on() - begins querying the model on a given datasource. (defined in October\Rain\Halcyon\Model)
- propertyExists() - checks if a property exists, extension equivalent of
property_exists(). (defined in October\Rain\Extension\Extendable) - query() - begins querying the model. (defined in October\Rain\Halcyon\Model)
- removeObservableEvents() - name. (defined in October\Rain\Halcyon\Model)
- resolveDatasource() - instance. (defined in October\Rain\Halcyon\Model)
- saveInternal() - Save the model to the database. Is used by {@link save()} and {@link forceSave()}. (defined in October\Rain\Halcyon\Model)
- saved() - Register a saved model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- saving() - Register a saving model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- setAttribute() - sets a given attribute on the model. (defined in October\Rain\Halcyon\Model)
- setCacheManager() - instance. (defined in October\Rain\Halcyon\Model)
- setDatasource() - associated with the model. (defined in October\Rain\Halcyon\Model)
- setDatasourceResolver() - instance. (defined in October\Rain\Halcyon\Model)
- setEventDispatcher() - instance. (defined in October\Rain\Halcyon\Model)
- setFileNameAttribute() - wjere file name should always contain an extension. (defined in October\Rain\Halcyon\Model)
- setLoadedFromCache() - returns true if the object was loaded from the cache. (defined in October\Rain\Halcyon\Model)
- setObservableEvents() - names. (defined in October\Rain\Halcyon\Model)
- setRawAttributes() - sets the array of model attributes. No checking is done. (defined in October\Rain\Halcyon\Model)
- setSettingsAttribute() - filling the settings should merge it with attributes. (defined in October\Rain\Halcyon\Model)
- syncOriginal() - attributes with the current. (defined in October\Rain\Halcyon\Model)
- syncOriginalAttribute() - syncs a single original attribute with its current value. (defined in October\Rain\Halcyon\Model)
- toArray() - converts the model instance to an array. (defined in October\Rain\Halcyon\Model)
- toJson() - converts the model instance to JSON. (defined in October\Rain\Halcyon\Model)
- unbindEvent() - destroys an event binding. (defined in October\Rain\Halcyon\Model)
- unsetCacheManager() - for models. (defined in October\Rain\Halcyon\Model)
- unsetDatasourceResolver() - for models. (defined in October\Rain\Halcyon\Model)
- unsetEventDispatcher() - for models. (defined in October\Rain\Halcyon\Model)
- update() - Update the model in the database. (defined in October\Rain\Halcyon\Model)
- updated() - Register an updated model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
- updating() - Register an updating model event with the dispatcher. (defined in October\Rain\Halcyon\Model)
Protected Methods
protected static boot()
protected static boot(): void
boot the model.
protected static bootDefaultTheme()
protected static bootDefaultTheme(): void
bootDefaultTheme and all of the bootable traits on the model.
protected getValidationAttributes()
protected getValidationAttributes(): array
getValidationAttributes returns the model data used for validation.
protected static makeValidator()
protected static makeValidator(
$data,
$rules,
$customMessages,
$attributeNames
): Illuminate\Validation\Validator
makeValidator instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel.
protected processRuleFieldNames()
protected processRuleFieldNames(array $rules): array
processRuleFieldNames converts any field names using array notation
(ie. field[child]) into dot notation (ie. field.child)
protected processValidationRules()
protected processValidationRules($rules): void
protected static throwHalcyonException()
protected static throwHalcyonException(Exception $ex): void
Converts an exception type thrown by Halcyon to a native CMS exception.
Show inherited protected methods
Inherited Protected Methods
- afterBoot() - is called after the model is constructed for the first time. (defined in October\Rain\Halcyon\Model)
- afterCreate() - handles the "created" model event. (defined in October\Rain\Halcyon\Model)
- afterDelete() - handles the "deleted" model event. (defined in October\Rain\Halcyon\Model)
- afterFetch() - handles the "fetched" model event. (defined in October\Rain\Halcyon\Model)
- afterInit() - is called after the model is constructed, a nicer version. (defined in October\Rain\Halcyon\Model)
- afterSave() - handles the "saved" model event. (defined in October\Rain\Halcyon\Model)
- afterUpdate() - handles the "updated" model event. (defined in October\Rain\Halcyon\Model)
- beforeCreate() - handles the "creating" model event. (defined in October\Rain\Halcyon\Model)
- beforeDelete() - handles the "deleting" model event. (defined in October\Rain\Halcyon\Model)
- beforeFetch() - handles the "fetching" model event. (defined in October\Rain\Halcyon\Model)
- beforeSave() - handles the "saving" model event. (defined in October\Rain\Halcyon\Model)
- beforeUpdate() - handles the "updating" model event. (defined in October\Rain\Halcyon\Model)
- bootIfNotBooted() - checks if the model needs to be booted and if so, do it. (defined in October\Rain\Halcyon\Model)
- bootNicerEvents() - binds some nicer events to this model, in the format of method overrides. (defined in October\Rain\Halcyon\Model)
- bootTraits() - boots all of the bootable traits on the model. (defined in October\Rain\Halcyon\Model)
- booted() - performs any actions required after the model boots. (defined in October\Rain\Halcyon\Model)
- booting() - performs any actions required before the model boots. (defined in October\Rain\Halcyon\Model)
- emitterEventSortEvents() - sorts the listeners for a given event by priority. (defined in October\Rain\Halcyon\Model)
- 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)
- fillableFromArray() - gets the fillable attributes of a given array. (defined in October\Rain\Halcyon\Model)
- finishSave() - Finish processing on a successful save operation. (defined in October\Rain\Halcyon\Model)
- fireModelEvent() - for the model. (defined in October\Rain\Halcyon\Model)
- getArrayableAppends() - gets all of the appendable values that are arrayable. (defined in October\Rain\Halcyon\Model)
- getAttributeFromArray() - gets an attribute from the $attributes array. (defined in October\Rain\Halcyon\Model)
- getExtendableMethodFromDynamicMethods() - (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromExtensions() - (defined in October\Rain\Extension\Extendable)
- initializeModelEvent() - is called every time the model is constructed. (defined in October\Rain\Halcyon\Model)
- initializeTraits() - on the model. (defined in October\Rain\Halcyon\Model)
- mutateAttribute() - gets the value of an attribute using its mutator. (defined in October\Rain\Halcyon\Model)
- mutateAttributeForArray() - gets the value of an attribute using its mutator for array conversion. (defined in October\Rain\Halcyon\Model)
- originalIsNumericallyEquivalent() - determine if the new and old values for a given key are. (defined in October\Rain\Halcyon\Model)
- performDeleteOnModel() - performs the actual delete query on this model instance. (defined in October\Rain\Halcyon\Model)
- performInsert() - Perform a model insert operation. (defined in October\Rain\Halcyon\Model)
- performUpdate() - Perform a model update operation. (defined in October\Rain\Halcyon\Model)
- registerModelEvent() - with the dispatcher. (defined in October\Rain\Halcyon\Model)