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

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


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

Show inherited public methods

Inherited Public Methods

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