YamlModel
extends BaseModel
in package
Base class for models that store data in YAML files.
Tags
Table of Contents
- $exists : bool
- $fillable : mixed
- $originalFileData : mixed
- $originalFilePath : mixed
- $pluginCodeObj : PluginCode
- $updatedData : mixed
- $validationMessages : mixed
- $validationRules : mixed
- $yamlSection : string
- deleteModel() : mixed
- fill() : mixed
- getModelPluginName() : mixed
- getPluginCodeObj() : mixed
- initDefaults() : mixed
- isNewModel() : mixed
- save() : mixed
- setPluginCode() : mixed
- Sets a string code of a plugin the model is associated with
- setPluginCodeObj() : mixed
- Sets a code object of a plugin the model is associated with
- validate() : mixed
- afterCreate() : mixed
- beforeCreate() : mixed
- getArrayKeySafe() : mixed
- getFilePath() : string
- Returns a file path to save the model to.
- load() : mixed
- modelToYamlArray() : array<string|int, mixed>
- Converts the model's data to an array before it's saved to a YAML file.
- validateBeforeCreate() : mixed
- yamlArrayToModel() : mixed
- Load the model's data from an array.
Properties
$exists
public
bool
$exists
= false
This property is used by the system internally.
$fillable
protected
static mixed
$fillable
= []
$originalFileData
protected
mixed
$originalFileData
= []
$originalFilePath
protected
mixed
$originalFilePath
$pluginCodeObj
protected
PluginCode
$pluginCodeObj
= null
The plugin code object the model is associated with.
$updatedData
protected
mixed
$updatedData
= []
$validationMessages
protected
mixed
$validationMessages
= []
$validationRules
protected
mixed
$validationRules
= []
$yamlSection
protected
string
$yamlSection
Section in the YAML file to save the data into. If empty, the model contents uses the entire file.
Methods
deleteModel()
public
deleteModel() : mixed
Return values
mixed —fill()
public
fill(array<string|int, mixed> $attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
Return values
mixed —getModelPluginName()
public
getModelPluginName() : mixed
Return values
mixed —getPluginCodeObj()
public
getPluginCodeObj() : mixed
Return values
mixed —initDefaults()
public
initDefaults() : mixed
Return values
mixed —isNewModel()
public
isNewModel() : mixed
Return values
mixed —save()
public
save() : mixed
Return values
mixed —setPluginCode()
Sets a string code of a plugin the model is associated with
public
setPluginCode(string $code) : mixed
Parameters
- $code : string
-
Specifies the plugin code
Return values
mixed —setPluginCodeObj()
Sets a code object of a plugin the model is associated with
public
setPluginCodeObj(PluginCode $obj) : mixed
Parameters
- $obj : PluginCode
-
Specifies the plugin code object
Return values
mixed —validate()
public
validate() : mixed
Return values
mixed —afterCreate()
protected
afterCreate() : mixed
Return values
mixed —beforeCreate()
protected
beforeCreate() : mixed
Return values
mixed —getArrayKeySafe()
protected
getArrayKeySafe(mixed $array, mixed $key[, mixed $default = null ]) : mixed
Parameters
- $array : mixed
- $key : mixed
- $default : mixed = null
Return values
mixed —getFilePath()
Returns a file path to save the model to.
protected
abstract getFilePath() : string
Return values
string —Returns a path.
load()
protected
load(mixed $filePath) : mixed
Parameters
- $filePath : mixed
Return values
mixed —modelToYamlArray()
Converts the model's data to an array before it's saved to a YAML file.
protected
abstract modelToYamlArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —validateBeforeCreate()
protected
validateBeforeCreate() : mixed
Return values
mixed —yamlArrayToModel()
Load the model's data from an array.
protected
abstract yamlArrayToModel(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
-
An array to load the model fields from.