Layout
class Layout extends Model
Layout Template Class
Traits
Adds event related features to any class.
Extendable Trait Allows for "Private traits"
Properties
protected array | $extensionData | from ExtendableTrait | |
static protected array | $extendableCallbacks | from ExtendableTrait | |
static protected array | $extendableStaticMethods | from ExtendableTrait | |
static protected bool | $extendableGuardProperties | from ExtendableTrait | |
static protected ClassLoader | $extendableClassLoader | from ExtendableTrait | |
$implement | from Extendable | ||
$hidden | The attributes that should be hidden for serialization. |
from HidesAttributes | |
protected array | $visible | The attributes that should be visible in serialization. |
from HidesAttributes |
array | $attributes | The model's attributes. |
from HasAttributes |
protected array | $original | The model attribute's original state. |
from HasAttributes |
protected array | $changes | The changed model attributes. |
from HasAttributes |
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. |
from HasAttributes |
static protected array | $mutatorCache | The cache of the mutated attributes for each class. |
from HasAttributes |
protected array | $fillable | The attributes that are mass assignable. |
from GuardsAttributes |
protected array | $dispatchesEvents | The event map for the model. |
from HasEvents |
protected array | $observables | User exposed observable events. |
from HasEvents |
static protected CacheManager | $cache | The cache manager instance. |
from ManagesCache |
protected bool | $loadedFromCache | from ManagesCache | |
protected array | $emitterSingleEvents | from EventEmitter | |
protected array | $emitterEvents | from EventEmitter | |
protected array | $emitterEventSorted | from EventEmitter | |
static protected SourceResolverInterface | $resolver | The source resolver instance. |
from Model |
static | $dispatcher | from Model | |
static protected array | $booted | The array of booted models. |
from Model |
static protected array | $eventsBooted | The array of booted events. |
from Model |
protected | $source | from Model | |
protected string | $dirName | ||
protected array | $appends | The accessors to append to the model's array form. |
from Model |
protected array | $purgeable | from Model | |
bool | $exists | Indicates if the model exists. |
from Model |
protected array | $allowedExtensions | from Model | |
protected string | $defaultExtension | from Model | |
protected int | $maxNesting | from Model | |
BaseComponent[] | $components | from HasComponents | |
array | $viewBag | from HasViewBag | |
protected mixed | $viewBagCache | from HasViewBag | |
protected Theme | $themeCache | from Model | |
$settings | from Model | ||
$controller |
Methods
Helper method for ::extend() static method
Clear the list of extended classes so they will be re-extended.
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Dynamically extend a class with a specified behavior
Extracts the available methods from a behavior and adds it to the list of callable methods.
Programmatically adds a method to the extendable class
Programatically adds a property to the extendable class
Check if extendable class is extended with a behavior object
Returns a behavior object from an extendable class, example:
Short hand for getClassExtension() method, except takes the short extension name, example:
Checks if a method exists, extension equivalent of method_exists()
Get a list of class methods, extension equivalent of get_class_methods()
Checks if a property exists, extension equivalent of property_exists()
Checks if a property is accessible, property equivalent of is_callabe()
Magic method for __call()
Magic method for __callStatic()
Implements getter functionality for visible properties defined in the settings section or view bag array.
Handle dynamic static method calls into the method.
Add hidden attributes for the model.
Add visible attributes for the model.
Make the given, typically hidden, attributes visible.
Make the given, typically visible, attributes hidden.
Add the mutated attributes to the attributes array.
Get an attribute array of all arrayable attributes.
Get an attribute array of all arrayable values.
Get an attribute from the $attributes array.
Determine if a get mutator exists for an attribute.
Get the value of an attribute using its mutator.
Get the value of an attribute using its mutator for array conversion.
Set a given attribute on the model.
Determine if a set mutator exists for an attribute.
Set the array of model attributes. No checking is done.
Get the model's original attribute values.
Sync a single original attribute with its current value.
Determine if the model or given attribute(s) have been modified.
Determine if the model or given attribute(s) have remained the same.
Determine if the model or given attribute(s) have been modified.
Determine if the given attributes were changed.
Determine if the new and old values for a given key are equivalent.
Extract and cache all the mutated attributes of a class.
Get all of the attribute mutator methods.
Get the fillable attributes of a given array.
Determine if the given attribute may be mass assigned.
Remove an observable event name.
Register a model event with the dispatcher.
Bind some nicer events to this model, in the format of method overrides.
Fire the given event for the model.
Fire a custom model event for the given event.
Register a saving model event with the dispatcher.
Register a saved model event with the dispatcher.
Register an updating model event with the dispatcher.
Register an updated model event with the dispatcher.
Register a creating model event with the dispatcher.
Register a created model event with the dispatcher.
Register a deleting model event with the dispatcher.
Register a deleted model event with the dispatcher.
Set the event dispatcher instance.
Initializes the object properties from the cached data. The extra data set here becomes available as attributes set on the model after fetch.
Returns true if the object was loaded from the cache.
Create a new event binding.
Create a new event binding that fires once only
Sort the listeners for a given event by priority.
Fire an event and call the listeners.
Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.
Clear the list of booted models so they will be re-booted.
Create a collection of models from plain arrays.
The settings is attribute contains everything that should be saved to the settings area.
Returns the allowable file extensions supported by this model.
Returns the base file name and extension. Applies a default extension, if none found.
Create a new instance of the given model.
Create a new model instance that is existing.
Save the model to the database. Is used by save()} and {@link forceSave().
Returns a component by its name.
Checks if the object has a component with the specified name.
Returns the list of objects in the specified theme.
No description
Returns name of a PHP class to use as parent for the PHP class created for the template's PHP section.
Details
in
ExtendableTrait at line 55
extendableConstruct()
Constructor.
in
ExtendableTrait at line 103
static void
extendableExtendCallback(callable $callback)
Helper method for ::extend() static method
in
ExtendableTrait at line 120
static void
clearExtendedClasses()
Clear the list of extended classes so they will be re-extended.
in
ExtendableTrait at line 131
protected string
extensionNormalizeClassName(string $name)
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
in
ExtendableTrait at line 149
void|ExtendableTrait
extendClassWith(string $extensionName)
Dynamically extend a class with a specified behavior
in
ExtendableTrait at line 178
protected void
extensionExtractMethods(string $extensionName, object $extensionObject)
Extracts the available methods from a behavior and adds it to the list of callable methods.
in
ExtendableTrait at line 206
addDynamicMethod(string $dynamicName, callable $method, string $extension = null)
Programmatically adds a method to the extendable class
in
ExtendableTrait at line 225
addDynamicProperty(string $dynamicName, string $value = null)
Programatically adds a property to the extendable class
in
ExtendableTrait at line 249
bool
isClassExtendedWith(string $name)
Check if extendable class is extended with a behavior object
in
ExtendableTrait at line 265
mixed
getClassExtension(string $name)
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Admin.Actions.FormController')
in
ExtendableTrait at line 280
mixed
asExtension(string $shortName)
Short hand for getClassExtension() method, except takes the short extension name, example:
$this->asExtension('FormController')
in
ExtendableTrait at line 301
bool
methodExists(string $name)
Checks if a method exists, extension equivalent of method_exists()
in
ExtendableTrait at line 313
array
getClassMethods()
Get a list of class methods, extension equivalent of get_class_methods()
in
ExtendableTrait at line 326
array
getDynamicProperties()
Returns all dynamic properties and their values
in
ExtendableTrait at line 344
bool
propertyExists(string $name)
Checks if a property exists, extension equivalent of property_exists()
in
ExtendableTrait at line 370
protected bool
extendableIsAccessible(mixed $class, string $propertyName)
Checks if a property is accessible, property equivalent of is_callabe()
in
ExtendableTrait at line 385
string
extendableGet(string $name)
Magic method for __get()
in
ExtendableTrait at line 410
string
extendableSet(string $name, string $value)
Magic method for __set()
in
ExtendableTrait at line 444
mixed
extendableCall(string $name, array $params = null)
Magic method for __call()
in
ExtendableTrait at line 483
static mixed
extendableCallStatic(string $name, array $params = null)
Magic method for __callStatic()
in
ExtendableTrait at line 552
protected ClassLoader|null
extensionGetClassLoader()
Gets the class loader
in
Model at line 98
__construct(array $attributes = [])
Create a new Halcyon model instance.
in
Model at line 260
__get($name)
Implements getter functionality for visible properties defined in the settings section or view bag array.
in
Model at line 276
__set(string $key, $value)
Dynamically set attributes on the model.
in
Model at line 738
__call(string $method, array $parameters)
Handle dynamic method calls into the model.
in
Model at line 758
static
__callStatic(string $method, array $parameters)
Handle dynamic static method calls into the method.
in
Extendable at line 50
static
extend(callable $callback)
No description
in
HidesAttributes at line 26
array
getHidden()
Get the hidden attributes for the model.
in
HidesAttributes at line 38
$this
setHidden(array $hidden)
Set the hidden attributes for the model.
in
HidesAttributes at line 52
void
addHidden(array|string|null $attributes = null)
Add hidden attributes for the model.
in
HidesAttributes at line 64
array
getVisible()
Get the visible attributes for the model.
in
HidesAttributes at line 76
$this
setVisible(array $visible)
Set the visible attributes for the model.
in
HidesAttributes at line 90
void
addVisible(array|string|null $attributes = null)
Add visible attributes for the model.
in
HidesAttributes at line 104
$this
makeVisible(array|string $attributes)
Make the given, typically hidden, attributes visible.
in
HidesAttributes at line 122
$this
makeHidden(array|string $attributes)
Make the given, typically visible, attributes hidden.
in
HasAttributes at line 51
array
attributesToArray()
Convert the model's attributes to an array.
in
HasAttributes at line 77
protected array
addMutatedAttributesToArray(array $attributes, array $mutatedAttributes)
Add the mutated attributes to the attributes array.
in
HasAttributes at line 103
protected array
getArrayableAttributes()
Get an attribute array of all arrayable attributes.
in
HasAttributes at line 113
protected array
getArrayableAppends()
Get all of the appendable values that are arrayable.
in
HasAttributes at line 131
protected array
getArrayableItems(array $values)
Get an attribute array of all arrayable values.
in
HasAttributes at line 151
mixed
getAttribute(string $key)
Get an attribute from the model.
in
HasAttributes at line 187
mixed
getAttributeValue(string $key)
Get a plain attribute (not a relationship).
in
HasAttributes at line 208
protected mixed
getAttributeFromArray(string $key)
Get an attribute from the $attributes array.
in
HasAttributes at line 222
bool
hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
in
HasAttributes at line 235
protected mixed
mutateAttribute(string $key, mixed $value)
Get the value of an attribute using its mutator.
in
HasAttributes at line 248
protected mixed
mutateAttributeForArray(string $key, mixed $value)
Get the value of an attribute using its mutator for array conversion.
in
HasAttributes at line 263
$this
setAttribute(string $key, mixed $value)
Set a given attribute on the model.
in
HasAttributes at line 286
bool
hasSetMutator(string $key)
Determine if a set mutator exists for an attribute.
in
HasAttributes at line 296
array
getAttributes()
Get all of the current attributes on the model.
in
HasAttributes at line 309
$this
setRawAttributes(array $attributes, bool $sync = false)
Set the array of model attributes. No checking is done.
in
HasAttributes at line 328
mixed|array
getOriginal(string|null $key = null, mixed $default = null)
Get the model's original attribute values.
in
HasAttributes at line 340
array
only(array|mixed $attributes)
Get a subset of the model's attributes.
in
HasAttributes at line 356
$this
syncOriginal()
Sync the original attributes with the current.
in
HasAttributes at line 370
$this
syncOriginalAttribute(string $attribute)
Sync a single original attribute with its current value.
in
HasAttributes at line 382
$this
syncChanges()
Sync the changed attributes.
in
HasAttributes at line 396
bool
isDirty(array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
in
HasAttributes at line 410
bool
isClean(array|string|null $attributes = null)
Determine if the model or given attribute(s) have remained the same.
in
HasAttributes at line 422
bool
wasChanged(array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
in
HasAttributes at line 437
protected bool
hasChanges(array $changes, array|string|null $attributes = null)
Determine if the given attributes were changed.
in
HasAttributes at line 463
array
getDirty()
Get the attributes that have been changed since last sync.
in
HasAttributes at line 481
array
getChanges()
Get the attributes that was changed.
in
HasAttributes at line 494
protected bool
originalIsEquivalent(string $key, mixed $current)
Determine if the new and old values for a given key are equivalent.
in
HasAttributes at line 518
array
getMutatedAttributes()
Get the mutated attributes for a given instance.
in
HasAttributes at line 536
static void
cacheMutatedAttributes(string $class)
Extract and cache all the mutated attributes of a class.
in
HasAttributes at line 550
static protected array
getMutatorMethods(mixed $class)
Get all of the attribute mutator methods.
in
GuardsAttributes at line 21
array
getFillable()
Get the fillable attributes for the model.
in
GuardsAttributes at line 33
$this
fillable(array $fillable)
Set the fillable attributes for the model.
in
GuardsAttributes at line 47
protected array
fillableFromArray(array $attributes)
Get the fillable attributes of a given array.
in
GuardsAttributes at line 65
bool
isFillable(string $key)
Determine if the given attribute may be mass assigned.
in
HasEvents at line 34
static void
observe(object|string $class)
Register an observer with the Model.
in
HasEvents at line 55
array
getObservableEvents()
Get the observable event names.
in
HasEvents at line 74
$this
setObservableEvents(array $observables)
Set the observable event names.
in
HasEvents at line 88
void
addObservableEvents(array|mixed $observables)
Add an observable event name.
in
HasEvents at line 102
void
removeObservableEvents(array|mixed $observables)
Remove an observable event name.
in
HasEvents at line 118
static protected void
registerModelEvent(string $event, Closure|string $callback, int $priority = 0)
Register a model event with the dispatcher.
in
HasEvents at line 130
protected
bootNicerEvents()
Bind some nicer events to this model, in the format of method overrides.
in
HasEvents at line 177
protected mixed
fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
in
HasEvents at line 209
protected mixed|null
fireCustomModelEvent(string $event, string $method)
Fire a custom model event for the given event.
in
HasEvents at line 229
protected mixed
filterModelEventResults(mixed $result)
Filter the model event results.
in
HasEvents at line 247
static void
retrieving(Closure|string $callback)
Create a new native event for handling beforeFetch().
in
HasEvents at line 259
static void
retrieved(Closure|string $callback)
Register a retrieved model event with the dispatcher.
in
HasEvents at line 272
static void
saving(Closure|string $callback, int $priority = 0)
Register a saving model event with the dispatcher.
in
HasEvents at line 285
static void
saved(Closure|string $callback, int $priority = 0)
Register a saved model event with the dispatcher.
in
HasEvents at line 298
static void
updating(Closure|string $callback, int $priority = 0)
Register an updating model event with the dispatcher.
in
HasEvents at line 311
static void
updated(Closure|string $callback, int $priority = 0)
Register an updated model event with the dispatcher.
in
HasEvents at line 324
static void
creating(Closure|string $callback, int $priority = 0)
Register a creating model event with the dispatcher.
in
HasEvents at line 337
static void
created(Closure|string $callback, int $priority = 0)
Register a created model event with the dispatcher.
in
HasEvents at line 350
static void
deleting(Closure|string $callback, int $priority = 0)
Register a deleting model event with the dispatcher.
in
HasEvents at line 363
static void
deleted(Closure|string $callback, int $priority = 0)
Register a deleted model event with the dispatcher.
in
HasEvents at line 373
static void
flushEventListeners()
Remove all of the event listeners for the model.
in
HasEvents at line 391
static Dispatcher
getEventDispatcher()
Get the event dispatcher instance.
in
HasEvents at line 403
static void
setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
in
HasEvents at line 413
static void
unsetEventDispatcher()
Unset the event dispatcher for models.
in
ManagesCache at line 22
static CacheManager
getCacheManager()
Get the cache manager instance.
in
ManagesCache at line 34
static void
setCacheManager(CacheManager $cache)
Set the cache manager instance.
in
ManagesCache at line 43
static void
unsetCacheManager()
Unset the cache manager for models.
in
ManagesCache at line 54
static
initCacheItem($item)
Initializes the object properties from the cached data. The extra data set here becomes available as attributes set on the model after fetch.
in
ManagesCache at line 62
bool
isLoadedFromCache()
Returns true if the object was loaded from the cache.
in
ManagesCache at line 74
void
setLoadedFromCache($value)
Returns true if the object was loaded from the cache.
in
EventEmitter at line 36
EventEmitter
bindEvent(string $event, callable $callback, int $priority = 0)
Create a new event binding.
in
EventEmitter at line 52
EventEmitter
bindEventOnce(string $event, callable $callback)
Create a new event binding that fires once only
in
EventEmitter at line 66
protected void
emitterEventSortEvents(string $eventName)
Sort the listeners for a given event by priority.
in
EventEmitter at line 84
EventEmitter
unbindEvent(string $event = null)
Destroys an event binding.
in
EventEmitter at line 124
string|array
fireEvent(string $event, array $params = [], bool $halt = false)
Fire an event and call the listeners.
in
EventEmitter at line 178
mixed
fireSystemEvent(string $event, array $params = [], bool $halt = true)
Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.
For example:
$this->fireSystemEvent('admin.form.myEvent', ['my value']);
Is equivalent to:
$this->fireEvent('form.myEvent', ['myvalue'], true);
Event::fire('admin.form.myEvent', [$this, 'myvalue'], true);
in
Model at line 116
protected void
bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
in
Model at line 40
static protected void
boot()
The "booting" method of the model.
in
Model at line 144
static protected void
bootTraits()
Boot all of the bootable traits on the model.
in
Model at line 160
static void
clearBootedModels()
Clear the list of booted models so they will be re-booted.
in
Model at line 184
static SourceInterface
resolveSource(string|null $source = null)
No description
in
Model at line 193
static SourceResolverInterface
getSourceResolver()
Get the source resolver instance.
in
Model at line 205
static void
setSourceResolver(SourceResolverInterface $resolver)
Set the source resolver instance.
in
Model at line 214
static void
unsetSourceResolver()
Unset the source resolver for models.
in
Model at line 227
static Collection
hydrate(array $items, string|null $source = null)
Create a collection of models from plain arrays.
in
Model at line 246
static Model
create(array $attributes = [])
Save a new model and return the instance.
in
Model at line 286
$this
fill(array $attributes)
Fill the model with an array of attributes.
in
Model at line 300
SourceInterface
getSource()
No description
in
Model at line 321
string
getSourceName()
Get the current source name for the model.
in
Model at line 330
string
getBaseFileNameAttribute()
Returns the file name without the extension.
in
Model at line 345
array
getSettingsAttribute()
The settings is attribute contains everything that should be saved to the settings area.
in
Model at line 364
setSettingsAttribute(mixed $value)
Filling the settings should merge it with attributes.
in
Model at line 375
setFileNameAttribute(mixed $value)
File name should always contain an extension.
in
Model at line 391
string
getTypeDirName()
Returns the directory name corresponding to the object type.
For pages the directory name is "_pages", for layouts - "_layouts", etc.
in
Model at line 400
array
getAllowedExtensions()
Returns the allowable file extensions supported by this model.
in
Model at line 409
int
getMaxNesting()
Returns the maximum directory nesting allowed by this template.
in
Model at line 421
array
getFileNameParts(string $fileName = null)
Returns the base file name and extension. Applies a default extension, if none found.
in
Model at line 466
Collection
newCollection(array $models = [])
Create a new Collection instance.
in
Model at line 479
Model
newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
in
Model at line 499
Model
newFromFinder(array $attributes = [], string|null $source = null)
Create a new model instance that is existing.
in
Model at line 519
bool|int
update(array $attributes = [])
Update the model in the database.
in
Model at line 535
bool
save(array $options = [])
Save the model to the source.
in
Model at line 547
bool
saveInternal(array $options = [])
Save the model to the database. Is used by save()} and {@link forceSave().
in
Model at line 584
protected void
finishSave(array $options)
Finish processing on a successful save operation.
in
Model at line 601
protected bool
performUpdate(Finder $query, array $options = [])
Perform a model update operation.
in
Model at line 633
protected bool
performInsert(Finder $query, array $options = [])
Perform a model insert operation.
in
Model at line 662
bool|null
delete()
Delete the model from the database.
in
Model at line 691
protected void
performDeleteOnModel()
Perform the actual delete query on this model instance.
in
Model at line 700
string
__toString()
Convert the model to its string representation.
in
Model at line 291
bool
__isset(string $key)
Determine if an attribute exists on the object.
in
Model at line 788
void
__unset(string $key)
Unset an attribute on the model.
in
Model at line 800
bool
offsetExists(mixed $offset)
Determine if the given attribute exists.
in
Model at line 812
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
in
Model at line 825
void
offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
in
Model at line 837
void
offsetUnset(mixed $offset)
Unset the value for a given offset.
in
Model at line 846
array
toArray()
Get the instance as an array.
in
Model at line 858
string
toJson(int $options = 0)
Convert the model instance to JSON.
in
Model at line 868
array
jsonSerialize()
Convert the object into something JSON serializable.
in
HasComponents at line 19
static void
bootHasComponents()
Boot the sortable trait for this model.
in
HasComponents at line 26
parseComponentSettings()
No description
in
HasComponents at line 52
BaseComponent
getComponent(string $componentName)
Returns a component by its name.
This method is used only in the admin and for internal system needs when the standard way to access components is not an option.
in
HasComponents at line 71
mixed
hasComponent(string $componentName)
Checks if the object has a component with the specified name.
in
HasComponents at line 96
runComponents()
No description
in
HasComponents at line 110
updateComponent($alias, array $properties)
No description
in
HasViewBag at line 25
static void
bootHasViewBag()
Boot the sortable trait for this model.
in
HasViewBag at line 32
parseSettings()
No description
in
HasViewBag at line 43
ViewBag
getViewBag()
Returns the configured view bag component.
This method is used only in the back-end and for internal system needs when the standard way to access components is not an option.
in
HasViewBag at line 66
protected void
fillViewBagArray()
Copies view bag properties to the view bag array.
This is required for the back-end editors.
in
Model at line 50
static protected void
bootDefaultTheme()
Boot all of the bootable traits on the model.
in
Model at line 72
static mixed
load(Theme $theme, string $fileName)
Loads the object from a file.
This method is used in the admin. It doesn't use any caching.
in
Model at line 86
static mixed
loadCached(Theme $theme, string $fileName)
Loads the object from a cache.
This method is used by the main in the runtime. If the cache is not found, it is created.
in
Model at line 102
static array|Collection
listInTheme(Theme $theme, bool $skipCache = FALSE)
Returns the list of objects in the specified theme.
This method is used internally by the system.
in
Model at line 125
static
getDropdownOptions(Theme $theme = null, $skipCache = FALSE)
No description
in
Model at line 149
string
getId()
Returns the unique id of this object.
ex. account/login.blade.php => account-login
in
Model at line 160
Theme
getThemeAttribute($value = null)
Returns the theme this object belongs to.
in
Model at line 182
string
getFilePath(string $fileName = null)
Returns the local file path to the template.
in
Model at line 200
string
getFileName()
Returns the file name.
in
Model at line 209
string
getBaseFileName()
Returns the file name without the extension.
in
Model at line 218
string
getContent()
Returns the file content.
in
Model at line 227
string
getMarkup()
Gets the markup section of a template
in
Model at line 236
string
getCode()
Gets the code section of a template
in
Model at line 245
string
getTemplateCacheKey()
Returns the key used by the Template cache.
at line 17
static
initFallback($theme)
No description
at line 31
mixed
getCodeClassParent()
Returns name of a PHP class to use as parent for the PHP class created for the template's PHP section.