Download the PHP package fyre/entity without Composer
On this page you can find all versions of the php package fyre/entity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package entity
FyreEntity
FyreEntity is a free, open-source entity library for PHP.
Table Of Contents
- Installation
- Entity Creation
- Methods
- Mutations
- Entity Locator
Installation
Using Composer
In PHP:
Entity Creation
$data
is an array containing the data for populating the entity.$options
is an array containing the options for creating the entity.source
is a string representing the entity source, and will default to null.new
is a boolean indicating whether the entity is new, and will default to true.clean
is a boolean indicating whether to clean the entity after init, and will default to true.
Methods
Clean
Clean the entity.
Clear
Clear values from the entity.
$fields
is an array containing the fields to clear.
Extract
Extract values from the entity.
$fields
is an array containing the fields to extract.
Extract Dirty
Extract dirty values from the entity.
$fields
is an array containing the fields to extract.
If the $field
argument is omitted, this method will return all dirty values.
Extract Original
Extract original values from the entity.
$fields
is an array containing the fields to extract.
Fill
Fill the entity with values.
$fields
is an array containing the data to fill.$options
is an array containing options for filling the entity.guard
is a boolean indicating whether to check whether the field is accessible, and will default to true.mutate
is a boolean indicating whether to mutate the value, and will default to true.
If the mutate
option is set to true, and a _setFieldName
method exists in the entity (where the field name is field_name), then that method will be called for each value being set. The argument will be the value being populated, and the return value of that method will be stored in the entity instead.
Fill Invalid
Fill the entity with invalid values.
$fields
is an array containing the data to fill.$overwrite
is a boolean indicating whether to overwrite existing values, and will default to false.
Get
Get a value from the entity.
$field
is a string representing the field name.
Alternatively, you can get a value using the magic __get
method or array syntax.
If a _getFieldName
method exists in the entity (where the field name is field_name), then that method will be called for the value being retrieved. The argument of that method will be the value stored in the entity, and the return value of that method will be returned instead.
Get Accessible
Get the accessible fields from the entity.
Get Dirty
Get the dirty fields from the entity.
Get Error
Get the errors for an entity field.
$field
is a string representing the field name.
Get Errors
Get all errors for the entity.
Get Hidden
Get the hidden fields from the entity.
Get Invalid
Get invalid value(s) from the entity.
$field
is a string representing the field name.
If the $field
argument is omitted, this method will return all invalid values.
Get Original
Get an original value from the entity.
$field
is a string representing the field name.
If the $field
argument is omitted, this method will return all original values.
Get Source
Get the entity source.
Get Virtual
Get the virtual fields from the entity.
Get Visible
Get the visible fields from the entity.
Has
Determine if an entity value is set.
$field
is a string representing the field name.
Alternatively, you can determine if a value is set using the magic __isset
method or array syntax.
Has Value
Determine if an entity value is not empty.
$field
is a string representing the field name.
Has Errors
Determine if the entity has errors.
Is Accessible
Determine if an entity field is accessible.
$field
is a string representing the field name.
Is Dirty
Determine if an entity field is dirty.
$field
is a string representing the field name.
If the $field
argument is omitted, this method will determine whether the entity has any dirty fields.
Is Empty
Determine if an entity value is empty.
$field
is a string representing the field name.
If the $field
argument is omitted, this method will determine whether all entity fields are empty.
Is New
Determine if the entity is new.
Set
Set an entity value.
$field
is a string representing the field name.$value
is the value to set.$options
is an array containing options for filling the entity.guard
is a boolean indicating whether to check whether the field is accessible, and will default to true.mutate
is a boolean indicating whether to mutate the value, and will default to true.
Alternatively, you can set a value using the magic __set
method or array syntax.
If the mutate
option is set to true, and a _setFieldName
method exists in the entity (where the field name is field_name), then that method will be called for the value being set. The argument will be the value being populated, and the return value of that method will be stored in the entity instead.
Set Access
Set whether a field is accessible.
$field
is a string representing the field name.$accessible
is a boolean indicating whether the field is accessible.
Set Dirty
Set whether a field is dirty.
$field
is a string representing the field name.$dirty
is a boolean indicating whether the field is dirty, and will default to true.
Set Error
Set errors for an entity field.
$field
is a string representing the field name.$error
is a string or array containing the errors.$overwrite
is a boolean indicating whether to overwrite existing errors, and will default to false.
Set Errors
Set all errors for the entity.
$errors
is an array containing the errors.$overwrite
is a boolean indicating whether to overwrite existing errors, and will default to false.
Set Hidden
Set hidden fields.
$field
is an array containing the field names.$merge
is a boolean indicating whether to merge with existing fields.
Set Invalid
Set an invalid value.
$field
is a string representing the field name.$value
is the value to set.$overwrite
is a boolean indicating whether to overwrite existing errors, and will default to true.
Set New
Set whether the entity is new.
$new
is a boolean whether the entity is new, and will default to true.
Set Source
Set the entity source.
$source
is a string representing the source.
Set Virtual
Set virtual fields.
$field
is an array containing the field names.$merge
is a boolean indicating whether to merge with existing fields.
To Array
Convert the entity to an array.
To JSON
Convert the entity to a JSON string.
Alternatively, you can cast the value to a string using the magic __toString
method.
Unset
Unset an entity value.
$field
is a string representing the field name.
Alternatively, you can unset a value using the magic __unset
method or array syntax.
Entity Locator
Add Namespace
Add a namespace for locating entities.
$namespace
is a string representing the namespace.
Clear
Clear all namespaces and entities.
Find
Find the entity class name for an alias.
$alias
is a string representing the alias.
Get Default Entity Class
Get the default entity class name.
Get Namespaces
Get the namespaces.
Has Namespace
Check if a namespace exists.
$namespace
is a string representing the namespace.
Remove Namespace
Remove a namespace.
$namespace
is a string representing the namespace.
Set Default Entity Class
Set the default entity class name.
$defaultEntityClass
is a string representing the default entity class name.