Method |
Description |
|
__call ( string $name, mixed $arguments ) : static |
Magic caller. It works like the magic setter and returns ourselves for chaining. If no arguments are passed we'll
only look for a scope filter. |
|
__construct ( Container $container, array $config = [] ) |
Public constructor. Overrides the parent constructor, adding support for database-aware models. |
|
__get ( string $name ) : static | mixed |
Magic getter. It will return the value of a field or, if no such field is found, the value of the relevant state
variable. |
|
__isset ( string $name ) : boolean |
Magic checker on a property. It follows the same logic of the __get magic method, however, if nothing is found, it
won't return the state of a variable (we are checking if a property is set) |
|
__set ( string $name, mixed $value ) : void |
Magic setter. It will set the value of a field or the value of a dynamic scope filter, or the value of the
relevant state variable. |
|
addBehaviour ( string $behaviour ) |
Adds a behaviour by its name. It will search the following classes, in this order:
\component_namespace\Model\modelName\Behaviour\behaviourName
\component_namespace\Model\DataModel\Behaviour\behaviourName
\FOF30\Model\DataModel\Behaviour\behaviourName
where:
component_namespace is the namespace of the component as defined in the container
modelName is the model's name, first character uppercase, e.g. Baz
behaviourName is the $behaviour parameter, first character uppercase, e.g. Something |
|
addKnownField ( string $fieldName, mixed $default = null, string $type = 'integer', boolean $replace = false ) |
Adds a known field to the DataModel. This is only necessary if you are using a custom buildQuery with JOINs or
field aliases. Please note that you need to make further modifications for bind() and save() to work in this
case. Please refer to the documentation blocks of these methods for more information. It is generally considered
a very BAD idea using JOINs instead of relations. It complicates your life and is bound to cause bugs that are
very hard to track back. |
|
addSkipCheckField ( string $fieldName ) : void |
Add a field to the list of fields to be ignored by the check() method |
|
applyAccessFiltering ( integer $userID = null ) : DataModel |
Applies view access level filtering for the specified user. Useful to
filter a front-end items listing. |
|
archive ( ) |
Archive the record, i.e. set enabled to 2 |
|
bind ( mixed $data, mixed $ignore = [] ) : static |
Method to bind an associative array or object to the DataModel instance. This method optionally takes an array of
properties to ignore when binding. |
|
blacklistFilters ( mixed $list = null, boolean $reset = false ) : void | array |
Set or get the backlisted filters |
|
buildQuery ( boolean $overrideLimits = false ) : JDatabaseQuery |
Build the query to fetch data from the database |
|
canDelete ( integer $oid = null, array $joins = null ) : void |
Generic check for whether dependencies exist for this object in the db schema. This method is NOT used by
default. If you want to use it you will have to override your delete(), trash() or forceDelete() method,
or create an onBeforeDelete and/or onBeforeTrash event handler. |
|
check ( ) : static |
Check the data for validity. By default it only checks for fields declared as NOT NULL |
|
checkContentType ( string $alias = null ) : null |
Check if a UCM content type exists for this resource, and
create it if it does not |
|
checkIn ( $userId = null ) |
Check-in an item. This works similar to unlock() but performs additional checks. If the item is locked by another
user you need to have adequate ACL privileges to unlock it, i.e. core.admin or core.manage component-wide
privileges; core.edit.state privileges component-wide or per asset; or be the creator of the item and have
core.edit.own privileges component-wide or per asset. |
|
chunk ( integer $chunkSize, callable $callback ) |
Process a large collection of records a few at a time. |
|
copy ( $data = null ) : DataModel |
Creates a copy of the current record. After the copy is performed, the data model contains the data of the new
record. |
|
count ( ) : integer |
Get the number of all items |
|
create ( array $data ) : static |
Create a new record with the provided data |
|
databaseDataToRecordData ( ) : void |
Applies the getSomethingAttribute methods to $this->recordData, converting the database representation of the
data to the record representation. $this->recordData is directly modified. |
|
delete ( mixed $id = null ) |
Automatically performs a hard or soft delete, based on the value of $this->softDelete. A soft delete simply sets
enabled to -2 whereas a hard delete removes the data from the database. If you want to force a specific behaviour
directly call trash() for a soft delete or forceDelete() for a hard delete. |
|
eagerLoad ( Collection &$dataCollection, array $relations = null ) |
Eager loads the provided relations and assigns their data to a data collection |
|
find ( array | mixed $keys = null ) : static |
Find and load a single record based on the provided key values |
|
findOrFail ( array | mixed $keys = null ) : static |
Find and load a single record based on the provided key values. If the record is not found an exception is thrown |
|
firstOrCreate ( array $data ) : static |
Return the first item found or create a new one based on the provided $data |
|
firstOrFail ( ) : static |
Return the first item found or throw a \RuntimeException |
|
firstOrNew ( ) : static |
Return the first item found or create a new, blank one |
|
forceDelete ( mixed $id = null ) |
Delete a record, either the currently loaded one or the one specified in $id. If an $id is specified that record
is loaded before trying to delete it. In the end the data model is reset. |
|
get ( boolean $overrideLimits = false, integer $limitstart, integer $limit ) : Collection |
Returns a DataCollection iterator based on your currently set Model state |
|
getAssetKey ( ) : string |
Method to compute the default name of the asset. |
|
getAssetName ( ) : string |
Method to compute the default name of the asset. |
|
getAssetParentId ( DataModel $model = null, integer $id = null ) : integer |
Method to get the parent asset under which to register this one. |
|
getAssetTitle ( ) : string |
Method to return the title to use for the asset table. In
tracking the assets a title is kept for each asset so that there is some
context available in a unified access manager. Usually this would just
return $this->title or $this->name or whatever is being used for the
primary name of the row. If this method is not overridden, the asset name is used. |
|
getBehaviorParam ( string $name, mixed $default = null ) : mixed |
Get a behavior param |
|
getBehavioursDispatcher ( ) : Dispatcher |
Gives you access to the behaviours dispatcher, allowing to attach/detach behaviour observers |
|
getContentType ( ) : string |
Get the content type for ucm |
|
getData ( ) : array |
Returns the data currently bound to the model in an array format. Similar to toArray() but returns a copy instead
of the internal table itself. |
|
getDbo ( ) : JDatabaseDriver |
Get the database connection associated with this data Model |
|
getFieldAlias ( string $alias ) : string |
Get the real name of a field name based on its alias. If the field is not aliased $alias is returned |
|
getFieldValue ( string $name, mixed $default = null ) : mixed |
Returns the value of a field. If a field is not set it uses the $default value. Automatically uses magic
getter variables if required. |
|
getFields ( ) : mixed |
Get the columns from database table. For JTableInterface compatibility. |
|
getForm ( array $data = [], boolean $loadData = true, boolean $source = null ) : Form | boolean |
A method for getting the form from the model. |
|
getFormName ( ) : string |
Gets the abstract XML form file name |
|
getId ( ) : mixed |
Return the value of the identity column of the currently loaded record |
|
getIdFieldName ( ) : string |
Returns the name of the table's id field (primary key) name |
|
getItemsArray ( integer $limitstart, integer $limit, boolean $overrideLimits = false ) : array |
Returns a raw array of DataModel instances based on your currently set Model state |
|
getKeyName ( ) : string |
Alias of getIdFieldName. Used for JTableInterface compatibility. |
|
getRawDataArray ( integer $limitstart, integer $limit, boolean $overrideLimits = false ) : array |
Returns the raw data array, as fetched from the database, based on your currently set Model state |
|
getRelationFields ( ) : array |
Returns an array mapping relation names to their local key field names. |
|
getRelationFilters ( ) : array |
Gets the relation filter definitions, for use by the RelationFilters behaviour |
|
getRelations ( ) : RelationManager |
Returns the relations manager of the model |
|
getRules ( ) : JAccessRules |
Method to get the rules for the record. |
|
getTableFields ( string $tableName = null ) : mixed |
Get the columns from a database table. |
|
getTableName ( ) : string |
Returns the database table name this model talks to |
|
getTouches ( ) : array |
Returns the list of relations which are touched by save() and touch() |
|
has ( string $relation, string $operator = '>=', mixed $value = 1, boolean $replace = true ) |
Filter the model based on the fulfilment of relations. For example:
$posts->has('comments', '>=', 10)->get();
will return all posts with at least 10 comments. |
|
hasField ( string $fieldName ) : boolean |
Does this model know about a field called $fieldName? Automatically uses aliases when necessary. |
|
hasSkipCheckField ( string $fieldName ) : boolean |
Is a field present in the list of fields to be ignored by the check() method? |
|
hasTags ( ) : boolean |
Gets the has tags switch state |
|
isAssetsTracked ( ) : boolean |
Method to check if the record is treated as an ACL asset |
|
isLocked ( integer $userId = null ) : boolean |
Is this record locked by a different user than $userId? |
|
load ( mixed $keys = null, boolean $reset = true ) : boolean |
Method to load a row from the database by primary key. Used for JTableInterface compatibility. |
|
loadhistory ( integer $version_id, string $alias ) : boolean |
Method to load a row for editing from the version history table. |
|
lock ( integer $userId = null ) |
Lock a record by setting its locked_on and/or locked_by columns |
|
move ( integer $delta, string $where = '' ) : static |
Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause. |
|
orderBy ( string $fieldName, string $direction = 'ASC' ) |
Set the field and direction of ordering for the query returned by buildQuery. |
|
publish ( integer $state = 1 ) |
Change the publish state of a record. By default it will set it to 1 (published) unless you specify a different
value. |
|
push ( null | array $data = null, string $orderingFilter = '', array $ignore = null, array $relations = null ) |
Save a record, creating it if it doesn't exist or updating it if it exists. By default it uses the currently set
data, unless you provide a $data array. On top of that, it also saves all specified relations. If $relations is
null it will save all relations known to this model. |
|
recordDataToDatabaseData ( ) : array |
Applies the setSomethingAttribute methods to $this->recordData, converting the record representation to database
representation. It does not modify $this->recordData, it returns a copy of the data array. |
|
removeBehaviour ( string $behaviour ) |
Removes a behaviour by its name. It will search the following classes, in this order:
\component_namespace\Model\modelName\Behaviour\behaviourName
\component_namespace\Model\DataModel\Behaviour\behaviourName
\FOF30\Model\DataModel\Behaviour\behaviourName
where:
component_namespace is the namespace of the component as defined in the container
modelName is the model's name, first character uppercase, e.g. Baz
behaviourName is the $behaviour parameter, first character uppercase, e.g. Something |
|
removeSkipCheckField ( string $fieldName ) : void |
Remove a field from the list of fields to be ignored by the check() method |
|
reorder ( string $where = '' ) : static |
Change the ordering of the records of the table |
|
reset ( boolean $useDefaults = true, boolean $resetRelations = false ) : static |
Reset the record data |
|
restore ( mixed $id = null ) |
Untrashes a record, either the currently loaded one or the one specified in $id. If an $id is specified that
record is loaded before trying to untrash it. Please note that enabled is set to 0 (unpublished) when you untrash
an item. |
|
save ( null | array $data = null, string $orderingFilter = '', array $ignore = null, $resetRelations = true ) : DataModel |
Save a record, creating it if it doesn't exist or updating it if it exists. By default it uses the currently set
data, unless you provide a $data array. |
|
setAssetKey ( string $assetKey ) : void |
This method sets the asset key for the items of this table. Obviously, it
is only meant to be used when you have a table with an asset field. |
|
setAssetsTracked ( $state ) |
Method to manually set this record as ACL asset or not. |
|
setBehaviorParam ( string $name, mixed $value ) |
Set a behavior param |
|
setFieldValue ( string $name, mixed $value = null ) : void |
Sets the value of a field. |
|
setFormName ( string $formName ) : void |
Sets the abstract XML form file name |
|
setHasTags ( boolean $newState = false ) |
Sets the has tags switch state |
|
setRules ( mixed $input ) : void |
Method to set rules for the record. |
|
skip ( integer $limitStart = null ) |
Set the limitStart for the query, i.e. how many records to skip. |
|
store ( boolean $updateNulls = false ) : boolean |
Alias of save. For JTableInterface compatibility. |
|
take ( integer $limit = null ) |
Set the limit for the query, i.e. how many records to return. |
|
tmpInstance ( ) |
Returns a temporary instance of the model. Please note that this returns a _clone_ of the model object, not the
original object. The new object is set up to not save its stats, ignore the request when getting state variables
and comes with an empty state. The temporary object instance has its data reset as well. |
|
toArray ( ) : array |
Return the record's data as an array |
|
toJson ( boolean $prettyPrint = false ) : string |
Returns the record's data as a JSON string |
|
touch ( integer $userId = null ) |
Touch a record, updating its modified_on and/or modified_by columns |
|
trash ( mixed $id = null ) |
Trashes a record, either the currently loaded one or the one specified in $id. If an $id is specified that record
is loaded before trying to trash it. Unlike a hard delete, trashing is a "soft delete", only setting the enabled
field to -2. |
|
unlock ( ) |
Unlock a record by resetting its locked_on and/or locked_by columns |
|
unpublish ( ) |
Unpublish the record, i.e. set enabled to 0 |
|
updateUcmContent ( ) : boolean |
This method is called by Joomla! itself when it needs to update the UCM content |
|
validateForm ( Form $form, array $data, string $group = null ) : mixed |
Method to validate the form data. |
|
where ( string $fieldName, string $method = '=', mixed $values = null ) |
Automatically uses the Filters behaviour to filter records in the model based on your criteria. |
|
whereHas ( string $relation, callable $callBack, boolean $replace = true ) |
Advanced model filtering on the fulfilment of relations. Unlike has() you can provide your own callback which
modifies the COUNT subquery used to compare against the relation. The $callBack has the signature
function(\JDatabaseQuery $query)
and MUST return a string. The $query you are passed is the COUNT subquery of the relation, e.g. |
|
whereRaw ( string $rawWhereClause ) |
Add custom, pre-compiled WHERE clauses for use in buildQuery. The raw WHERE clause you specify is added as is to
the query generated by buildQuery. You are responsible for quoting and escaping the field names and data found
inside the WHERE clause. |
|
with ( array $relations ) |
Instructs the model to eager load the specified relations. The $relations array can have the format: |
|