PHP Класс FOF30\Model\DataModel

Type hinting -- start
Наследование: extends Model, implements JTableInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_assetKey string The asset key for items in this table. It's usually something in the com_example.viewname format. They asset name will be this key appended with the item's ID, e.g. com_example.viewname.123
$_behaviorParams Shared parameters for behaviors
$_formData The data to load into a form
$_forms Array of form objects
$_has_tags Does the resource support joomla tags?
$_rules The rules associated with this record.
$_trackAssets Should rows be tracked as ACL assets?
$aliasFields Table field name aliases, defined as aliasFieldName => actualFieldName
$autoChecks Should I run automatic checks on the table data?
$autoFill Should I auto-fill the fields of the model object when constructing it?
$behavioursDispatcher An event dispatcher for model behaviours
$contentType The UCM content type (typically: com_something.viewname, e.g. com_foobar.items)
$dbo The database driver for this model
$eagerRelations A list of all eager loaded relations and their attached callbacks
$fieldsSkipChecks Which fields should be exempt from automatic checks when autoChecks is enabled
$fillable Which fields should be auto-filled from the model state (by extent, the request)?
$formName The name of the XML form to load
$guarded Which fields should never be auto-filled from the model state (by extent, the request)?
$idFieldName The identity field's name
$knownFields A hash array with the table fields we know about and their information. Each key is the field name, the value is the field information
$prefixCasePermutations A list of permutations of the prefix with upper/lowercase letters
$recordData The data of the current record
$relationFilters A list of the relation filter definitions for this model
$relationManager The relation manager of this model
$softDelete What will delete() do? True: trash (enabled set to -2); false: hard delete (remove from database)
$tableCache A list of tables in the database
$tableFieldCache A list of table fields, keyed per table
$tableName The name of the database table we connect to
$touches A list of the relations which will be auto-touched by save() and touch() methods
$whereClauses A collection of custom, additional where clauses to apply during buildQuery

Открытые методы

Метод Описание
__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:

Защищенные методы

Метод Описание
getAsset ( ) : boolean | JTableAsset Loads the asset table related to this table.
getPrefixCasePermutations ( ) : array Returns all lower and upper case permutations of the database prefix
getUcmCoreAlias ( string $alias, string $null = "null" ) : string Utility methods that fetches the column name for the field.
loadForm ( string $name, string $source, array $options = [], boolean $clear = false, boolean | string $xpath = false ) : Form | boolean Method to get a form object.
loadFormData ( ) : array Method to get the data that should be injected in the form.
preprocessForm ( Form &$form, &$data, string $group = 'content' ) : void Method to allow derived classes to preprocess the form.

Описание методов

__call() публичный метод

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.
public __call ( string $name, mixed $arguments ) : static
$name string
$arguments mixed
Результат static

__construct() публичный метод

You can use the $config array to pass some configuration values to the object: tableName String The name of the database table to use. Default: #__appName_viewNamePlural (Ruby on Rails convention) idFieldName String The table key field name. Default: appName_viewNameSingular_id (Ruby on Rails convention) knownFields Array The known fields in the table. Default: read from the table itself autoChecks Boolean Should I turn on automatic data validation checks? fieldsSkipChecks Array List of fields which should not participate in automatic data validation checks. aliasFields Array Associative array of "magic" field aliases. behavioursDispatcher EventDispatcher The model behaviours event dispatcher. behaviourObservers Array The model behaviour observers to attach to the behavioursDispatcher. behaviours Array A list of behaviour names to instantiate and attach to the behavioursDispatcher. fillable_fields Array Which fields should be auto-filled from the model state (by extent, the request)? guarded_fields Array Which fields should never be auto-filled from the model state (by extent, the request)? relations Array (hashed) The relations to autoload on model creation. contentType String The UCM content type, e.g. "com_foobar.items" Setting either fillable_fields or guarded_fields turns on automatic filling of fields in the constructor. If both are set only guarded_fields is taken into account. Fields are not filled automatically outside the constructor.
См. также: Model::__construct()
public __construct ( Container $container, array $config = [] )
$container FOF30\Container\Container The configuration variables to this model
$config array Configuration values for this model

__get() публичный метод

Tip: Trying to get fltSomething will always return the value of the state variable "something" Tip: You can define custom field getter methods as getFieldNameAttribute, where FieldName is your field's name, in CamelCase (even if the field name itself is in snake_case).
public __get ( string $name ) : static | mixed
$name string The name of the field / state variable to retrieve
Результат static | mixed

__isset() публичный метод

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)
public __isset ( string $name ) : boolean
$name string The name of the field to check
Результат boolean Is the field set?

__set() публичный метод

Tip: Trying to set fltSomething will always return the value of the state variable "something" Tip: Trying to set scopeSomething will always return the value of the dynamic scope filter "something" Tip: You can define custom field setter methods as setFieldNameAttribute, where FieldName is your field's name, in CamelCase (even if the field name itself is in snake_case).
public __set ( string $name, mixed $value ) : void
$name string The name of the field / scope / state variable to set
$value mixed The value to set
Результат void

addBehaviour() публичный метод

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
public addBehaviour ( string $behaviour )
$behaviour string The behaviour's name

addKnownField() публичный метод

Basically, if you find yourself using this method you are probably doing something very wrong or very advanced. If you do not feel confident with debugging FOF code STOP WHATEVER YOU'RE DOING and rethink your Model. Why are you using a JOIN? If you want to filter the records by a field found in another table you can still use relations and whereHas with a callback. If you want to display data from related entries in an XML form you can do that with relations, using the dot notation (name_from="relationName.fieldName"). If you want to do advanced grouping of records (GROUP clauses) then allright, you can't use relations. But if you are doing this kind of advanced stuff you needn't be reading introductory texts like this so get back to coding already!
public addKnownField ( string $fieldName, mixed $default = null, string $type = 'integer', boolean $replace = false )
$fieldName string The name of the field
$default mixed Default value, used by reset() (default: null)
$type string Database type for the field. If unsure use 'integer', 'float' or 'text'.
$replace boolean Should we replace an existing known field definition?

addSkipCheckField() публичный метод

Add a field to the list of fields to be ignored by the check() method
public addSkipCheckField ( string $fieldName ) : void
$fieldName string The field to add (can be a field alias)
Результат void

applyAccessFiltering() публичный метод

Applies view access level filtering for the specified user. Useful to filter a front-end items listing.
public applyAccessFiltering ( integer $userID = null ) : DataModel
$userID integer The user ID to use. Skip it to use the currently logged in user.
Результат DataModel Reference to self

archive() публичный метод

Archive the record, i.e. set enabled to 2
public archive ( )

bind() публичный метод

Special note if you are using a custom buildQuery with JOINs or field aliases: You will need to use addKnownField to let FOF know that the fields from your JOINs and the aliased fields should be bound to the record data. If you are using aliased fields you may also want to override the databaseDataToRecordData method. Generally, it is a BAD idea using JOINs instead of relations.
public bind ( mixed $data, mixed $ignore = [] ) : static
$data mixed An associative array or object to bind to the DataModel instance.
$ignore mixed An optional array or space separated list of properties to ignore while binding.
Результат static Self, for chaining

blacklistFilters() публичный метод

Set or get the backlisted filters
public blacklistFilters ( mixed $list = null, boolean $reset = false ) : void | array
$list mixed A filter or list of filters to backlist. If null return the list of backlisted filter
$reset boolean Reset the blacklist if true
Результат void | array Return an array of value if $list is null

buildQuery() публичный метод

Build the query to fetch data from the database
public buildQuery ( boolean $overrideLimits = false ) : JDatabaseQuery
$overrideLimits boolean Should I override limits
Результат JDatabaseQuery The database query to use

canDelete() публичный метод

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.
public canDelete ( integer $oid = null, array $joins = null ) : void
$oid integer The primary key of the record to delete
$joins array Any joins to foreign table, used to determine if dependent records exist
Результат void

check() публичный метод

Check the data for validity. By default it only checks for fields declared as NOT NULL
public check ( ) : static
Результат static Self, for chaining

checkContentType() публичный метод

Check if a UCM content type exists for this resource, and create it if it does not
public checkContentType ( string $alias = null ) : null
$alias string The content type alias (optional)
Результат null

checkIn() публичный метод

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.
public checkIn ( $userId = null )

chunk() публичный метод

Process a large collection of records a few at a time.
public chunk ( integer $chunkSize, callable $callback )
$chunkSize integer How many records to process at once
$callback callable A callable to process each record

copy() публичный метод

Creates a copy of the current record. After the copy is performed, the data model contains the data of the new record.
public copy ( $data = null ) : DataModel
Результат DataModel

count() публичный метод

Get the number of all items
public count ( ) : integer
Результат integer

create() публичный метод

Create a new record with the provided data
public create ( array $data ) : static
$data array The data to use in the new record
Результат static Self, for chaining

databaseDataToRecordData() публичный метод

Applies the getSomethingAttribute methods to $this->recordData, converting the database representation of the data to the record representation. $this->recordData is directly modified.
public databaseDataToRecordData ( ) : void
Результат void

delete() публичный метод

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.
public delete ( mixed $id = null )
$id mixed Primary key (id field) value

eagerLoad() публичный метод

Eager loads the provided relations and assigns their data to a data collection
public eagerLoad ( Collection &$dataCollection, array $relations = null )
$dataCollection FOF30\Model\DataModel\Collection The data collection on which the eager loaded relations will be applied
$relations array The relations to eager load. Leave empty to use the already defined relations

find() публичный метод

Find and load a single record based on the provided key values
public find ( array | mixed $keys = null ) : static
$keys array | mixed An optional primary key value to load the row by, or an array of fields to match. If not set the "id" state variable or, if empty, the identity column's value is used
Результат static Self, for chaining

findOrFail() публичный метод

Find and load a single record based on the provided key values. If the record is not found an exception is thrown
public findOrFail ( array | mixed $keys = null ) : static
$keys array | mixed An optional primary key value to load the row by, or an array of fields to match. If not set the "id" state variable or, if empty, the identity column's value is used
Результат static Self, for chaining

firstOrCreate() публичный метод

Return the first item found or create a new one based on the provided $data
public firstOrCreate ( array $data ) : static
$data array Data for the newly created item
Результат static

firstOrFail() публичный метод

Return the first item found or throw a \RuntimeException
public firstOrFail ( ) : static
Результат static

firstOrNew() публичный метод

Return the first item found or create a new, blank one
public firstOrNew ( ) : static
Результат static

forceDelete() публичный метод

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.
public forceDelete ( mixed $id = null )
$id mixed Primary key (id field) value

get() публичный метод

Returns a DataCollection iterator based on your currently set Model state
public get ( boolean $overrideLimits = false, integer $limitstart, integer $limit ) : Collection
$overrideLimits boolean Should I ignore limits set in the Model?
$limitstart integer How many items to skip from the start, only when $overrideLimits = true
$limit integer How many items to return, only when $overrideLimits = true
Результат FOF30\Model\DataModel\Collection The data collection

getAsset() защищенный метод

This will help tests, too, since we can mock this function.
protected getAsset ( ) : boolean | JTableAsset
Результат boolean | JTableAsset False on failure, otherwise JTableAsset

getAssetKey() публичный метод

The default name is in the form table_name.id where id is the value of the primary key of the table.
public getAssetKey ( ) : string
Результат string

getAssetName() публичный метод

The default name is in the form table_name.id where id is the value of the primary key of the table.
public getAssetName ( ) : string
Результат string

getAssetParentId() публичный метод

By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. The extended class can define a table and id to lookup. If the asset does not exist it will be created.
public getAssetParentId ( DataModel $model = null, integer $id = null ) : integer
$model DataModel A model object for the asset parent.
$id integer Id to look up
Результат integer

getAssetTitle() публичный метод

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.
public getAssetTitle ( ) : string
Результат string The string to use as the title in the asset table.

getBehaviorParam() публичный метод

Get a behavior param
public getBehaviorParam ( string $name, mixed $default = null ) : mixed
$name string The name of the param you want to get
$default mixed The default value returned if not set
Результат mixed

getBehavioursDispatcher() публичный метод

Gives you access to the behaviours dispatcher, allowing to attach/detach behaviour observers
public getBehavioursDispatcher ( ) : Dispatcher
Результат FOF30\Event\Dispatcher

getContentType() публичный метод

Get the content type for ucm
public getContentType ( ) : string
Результат string The content type alias

getData() публичный метод

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.
public getData ( ) : array
Результат array

getDbo() публичный метод

Get the database connection associated with this data Model
public getDbo ( ) : JDatabaseDriver
Результат JDatabaseDriver

getFieldAlias() публичный метод

Get the real name of a field name based on its alias. If the field is not aliased $alias is returned
public getFieldAlias ( string $alias ) : string
$alias string The field to get an alias for
Результат string The real name of the field

getFieldValue() публичный метод

Returns the value of a field. If a field is not set it uses the $default value. Automatically uses magic getter variables if required.
public getFieldValue ( string $name, mixed $default = null ) : mixed
$name string The name of the field to retrieve
$default mixed Default value, if the field is not set and doesn't have a getter method
Результат mixed The value of the field

getFields() публичный метод

Get the columns from database table. For JTableInterface compatibility.
public getFields ( ) : mixed
Результат mixed An array of the field names, or false if an error occurs.

getForm() публичный метод

A method for getting the form from the model.
С версии: 2.0
public getForm ( array $data = [], boolean $loadData = true, boolean $source = null ) : Form | boolean
$data array Data for the form.
$loadData boolean True if the form is to load its own data (default case), false if not.
$source boolean The name of the form. If not set we'll try the form_name state variable or fall back to default.
Результат FOF30\Form\Form | boolean A Form object on success, false on failure

getFormName() публичный метод

Gets the abstract XML form file name
public getFormName ( ) : string
Результат string The abstract form file name to set, e.g. "form.default"

getId() публичный метод

Return the value of the identity column of the currently loaded record
public getId ( ) : mixed
Результат mixed

getIdFieldName() публичный метод

Returns the name of the table's id field (primary key) name
public getIdFieldName ( ) : string
Результат string

getItemsArray() публичный метод

Returns a raw array of DataModel instances based on your currently set Model state
public getItemsArray ( integer $limitstart, integer $limit, boolean $overrideLimits = false ) : array
$limitstart integer How many items from the start to skip (0 = do not skip)
$limit integer How many items to return (0 = all)
$overrideLimits boolean Set to true to override limitstart, limit and ordering
Результат array Array of DataModel objects

getKeyName() публичный метод

Alias of getIdFieldName. Used for JTableInterface compatibility.
public getKeyName ( ) : string
Результат string The name of the primary key for the table.

getPrefixCasePermutations() защищенный метод

Returns all lower and upper case permutations of the database prefix
protected getPrefixCasePermutations ( ) : array
Результат array

getRawDataArray() публичный метод

Returns the raw data array, as fetched from the database, based on your currently set Model state
public getRawDataArray ( integer $limitstart, integer $limit, boolean $overrideLimits = false ) : array
$limitstart integer How many items from the start to skip (0 = do not skip)
$limit integer How many items to return (0 = all)
$overrideLimits boolean Set to true to override limitstart, limit and ordering
Результат array Array of hashed arrays

getRelationFields() публичный метод

For example, given a relation "foobar" with local key name "example_item_id" it will return: ["foobar" => "example_item_id"]
public getRelationFields ( ) : array
Результат array Array of [relationName => fieldName] arrays

getRelationFilters() публичный метод

Gets the relation filter definitions, for use by the RelationFilters behaviour
public getRelationFilters ( ) : array
Результат array

getRelations() публичный метод

Returns the relations manager of the model
public getRelations ( ) : RelationManager
Результат FOF30\Model\DataModel\RelationManager

getRules() публичный метод

Method to get the rules for the record.
public getRules ( ) : JAccessRules
Результат JAccessRules object

getTableFields() публичный метод

Get the columns from a database table.
public getTableFields ( string $tableName = null ) : mixed
$tableName string Table name. If null current table is used
Результат mixed An array of the field names, or false if an error occurs.

getTableName() публичный метод

Returns the database table name this model talks to
public getTableName ( ) : string
Результат string

getTouches() публичный метод

Returns the list of relations which are touched by save() and touch()
public getTouches ( ) : array
Результат array

getUcmCoreAlias() защищенный метод

If it does not exists, returns a "null" string
protected getUcmCoreAlias ( string $alias, string $null = "null" ) : string
$alias string The alias for the column
$null string What to return if no column exists
Результат string The column name

has() публичный метод

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.
public has ( string $relation, string $operator = '>=', mixed $value = 1, boolean $replace = true )
$relation string The relation to query
$operator string The comparison operator. Same operators as the where() method.
$value mixed The value(s) to compare against.
$replace boolean When true (default) any existing relation filters for the same relation will be replaced

hasField() публичный метод

Does this model know about a field called $fieldName? Automatically uses aliases when necessary.
public hasField ( string $fieldName ) : boolean
$fieldName string Field name to check
Результат boolean True if the field exists

hasSkipCheckField() публичный метод

Is a field present in the list of fields to be ignored by the check() method?
public hasSkipCheckField ( string $fieldName ) : boolean
$fieldName string The field to check (can be a field alias)
Результат boolean True if the field is skipped from checks, false if not or if the field doesn't exist.

hasTags() публичный метод

Gets the has tags switch state
public hasTags ( ) : boolean
Результат boolean

isAssetsTracked() публичный метод

Method to check if the record is treated as an ACL asset
public isAssetsTracked ( ) : boolean
Результат boolean [description]

isLocked() публичный метод

Is this record locked by a different user than $userId?
public isLocked ( integer $userId = null ) : boolean
$userId integer
Результат boolean True if the record is locked

load() публичный метод

Method to load a row from the database by primary key. Used for JTableInterface compatibility.
С версии: 3.2
public load ( mixed $keys = null, boolean $reset = true ) : boolean
$keys mixed An optional primary key value to load the row by, or an array of fields to match. If not set the instance property value is used.
$reset boolean True to reset the default values before loading the new row.
Результат boolean True if successful. False if row not found.

loadForm() защищенный метод

Method to get a form object.
См. также: Form
С версии: 2.0
protected loadForm ( string $name, string $source, array $options = [], boolean $clear = false, boolean | string $xpath = false ) : Form | boolean
$name string The name of the form.
$source string The form filename (e.g. form.browse)
$options array Optional array of options for the form creation.
$clear boolean Optional argument to force load a new form.
$xpath boolean | string An optional xpath to search for the fields.
Результат FOF30\Form\Form | boolean Form object on success, False on error.

loadFormData() защищенный метод

Method to get the data that should be injected in the form.
С версии: 2.0
protected loadFormData ( ) : array
Результат array The default data is an empty array.

loadhistory() публичный метод

Method to load a row for editing from the version history table.
С версии: 2.3
public loadhistory ( integer $version_id, string $alias ) : boolean
$version_id integer Key to the version history table.
$alias string The type_alias in #__content_types
Результат boolean True on success

lock() публичный метод

Lock a record by setting its locked_on and/or locked_by columns
public lock ( integer $userId = null )
$userId integer

move() публичный метод

Negative numbers move the row up in the sequence and positive numbers move it down.
public move ( integer $delta, string $where = '' ) : static
$delta integer The direction and magnitude to move the row in the ordering sequence.
$where string WHERE clause to use for limiting the selection of rows to compact the ordering values.
Результат static Self, for chaining

orderBy() публичный метод

Alias of $this->setState('filter_order', $fieldName) and $this->setState('filter_order_Dir', $direction)
public orderBy ( string $fieldName, string $direction = 'ASC' )
$fieldName string The field name to order by
$direction string The direction to order by (ASC for ascending or DESC for descending)

preprocessForm() защищенный метод

Method to allow derived classes to preprocess the form.
С версии: 2.0
protected preprocessForm ( Form &$form, &$data, string $group = 'content' ) : void
$form FOF30\Form\Form
$group string The name of the plugin group to import (defaults to "content").
Результат void

publish() публичный метод

Change the publish state of a record. By default it will set it to 1 (published) unless you specify a different value.
public publish ( integer $state = 1 )
$state integer The publish state. Default: 1 (published).

push() публичный метод

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.
public push ( null | array $data = null, string $orderingFilter = '', array $ignore = null, array $relations = null )
$data null | array [Optional] Data to bind
$orderingFilter string A WHERE clause used to apply table item reordering
$ignore array A list of fields to ignore when binding $data
$relations array Which relations to save with the model's record. Leave null for all relations

recordDataToDatabaseData() публичный метод

If you are using custom knownFields to cater for table JOINs you need to override this method and _remove_ the fields which do not belong to the table you are saving to. It's generally a bad idea using JOINs instead of relations. You have been warned!
public recordDataToDatabaseData ( ) : array
Результат array

removeBehaviour() публичный метод

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
public removeBehaviour ( string $behaviour )
$behaviour string The behaviour's name

removeSkipCheckField() публичный метод

Remove a field from the list of fields to be ignored by the check() method
public removeSkipCheckField ( string $fieldName ) : void
$fieldName string The field to remove (can be a field alias)
Результат void

reorder() публичный метод

Change the ordering of the records of the table
public reorder ( string $where = '' ) : static
$where string The WHERE clause of the SQL used to fetch the order
Результат static Self, for chaining

reset() публичный метод

Reset the record data
public reset ( boolean $useDefaults = true, boolean $resetRelations = false ) : static
$useDefaults boolean Should I use the default values? Default: yes
$resetRelations boolean Should I reset the relations too? Default: no
Результат static Self, for chaining

restore() публичный метод

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.
public restore ( mixed $id = null )
$id mixed Primary key (id field) value

save() публичный метод

Special note if you are using a custom buildQuery with JOINs or field aliases: You will need to override the recordDataToDatabaseData method. Make sure that you _remove_ or rename any fields which do not exist in the table defined in $this->tableName. Otherwise Joomla! will not know how to insert / update the data on the table and will throw an Exception denoting a database error. It is generally a BAD idea using JOINs instead of relations. If unsure, use relations.
public save ( null | array $data = null, string $orderingFilter = '', array $ignore = null, $resetRelations = true ) : DataModel
$data null | array [Optional] Data to bind
$orderingFilter string A WHERE clause used to apply table item reordering
$ignore array A list of fields to ignore when binding $data
Результат DataModel Self, for chaining

setAssetKey() публичный метод

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.
public setAssetKey ( string $assetKey ) : void
$assetKey string The name of the asset key to use
Результат void

setAssetsTracked() публичный метод

We have to do this since the automatic check is made in the constructor, but here we can't set any alias. So, even if you have an alias for asset_id, it wouldn't be reconized and assets won't be tracked.
public setAssetsTracked ( $state )
$state

setBehaviorParam() публичный метод

Set a behavior param
public setBehaviorParam ( string $name, mixed $value )
$name string The name of the param you want to set
$value mixed The value to set

setFieldValue() публичный метод

Sets the value of a field.
public setFieldValue ( string $name, mixed $value = null ) : void
$name string The name of the field to set
$value mixed The value to set it to
Результат void

setFormName() публичный метод

Sets the abstract XML form file name
public setFormName ( string $formName ) : void
$formName string The abstract form file name to set, e.g. "form.default"
Результат void

setHasTags() публичный метод

Sets the has tags switch state
public setHasTags ( boolean $newState = false )
$newState boolean

setRules() публичный метод

Method to set rules for the record.
public setRules ( mixed $input ) : void
$input mixed A JAccessRules object, JSON string, or array.
Результат void

skip() публичный метод

Alias of $this->setState('limitstart', $limitStart);
public skip ( integer $limitStart = null )
$limitStart integer Records to skip from the start

store() публичный метод

Alias of save. For JTableInterface compatibility.
public store ( boolean $updateNulls = false ) : boolean
$updateNulls boolean Blatantly ignored.
Результат boolean True on success.

take() публичный метод

Alias of $this->setState('limit', $limit);
public take ( integer $limit = null )
$limit integer Maximum number of 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.
public tmpInstance ( )

toArray() публичный метод

Return the record's data as an array
public toArray ( ) : array
Результат array

toJson() публичный метод

Returns the record's data as a JSON string
public toJson ( boolean $prettyPrint = false ) : string
$prettyPrint boolean Should I format the JSON for pretty printing
Результат string

touch() публичный метод

Touch a record, updating its modified_on and/or modified_by columns
public touch ( integer $userId = null )
$userId integer Optional user ID of the user touching the record

trash() публичный метод

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.
public trash ( mixed $id = null )
$id mixed Primary key (id field) value

unlock() публичный метод

Unlock a record by resetting its locked_on and/or locked_by columns
public unlock ( )

unpublish() публичный метод

Unpublish the record, i.e. set enabled to 0
public unpublish ( )

updateUcmContent() публичный метод

This method is called by Joomla! itself when it needs to update the UCM content
public updateUcmContent ( ) : boolean
Результат boolean

validateForm() публичный метод

Method to validate the form data.
См. также: JFormRule
См. также: JFilterInput
С версии: 2.0
public validateForm ( Form $form, array $data, string $group = null ) : mixed
$form FOF30\Form\Form The form to validate against.
$data array The data to validate.
$group string The name of the field group to validate.
Результат mixed Array of filtered data if valid, false otherwise.

where() публичный метод

Automatically uses the Filters behaviour to filter records in the model based on your criteria.
public where ( string $fieldName, string $method = '=', mixed $values = null )
$fieldName string The field name to filter on
$method string The filtering method, e.g. <>, =, != and so on
$values mixed The value you're filtering on. Some filters (e.g. interval or between) require an array of values

whereHas() публичный метод

SELECT COUNT(*) FROM #__comments AS reltbl WHERE reltbl.user_id = user_id You have to return a WHERE clause for the model's query, e.g. (SELECT COUNT(*) FROM #__comments AS reltbl WHERE reltbl.user_id = user_id) BETWEEN 1 AND 20
public whereHas ( string $relation, callable $callBack, boolean $replace = true )
$relation string The relation to query against
$callBack callable The callback to use for filtering
$replace boolean When true (default) any existing relation filters for the same relation will be replaced

whereRaw() публичный метод

Using this method is a generally bad idea. You are better off overriding buildQuery and using state variables to customise the query build built instead of using this method to push raw SQL to the query builder. Mixing your business logic with raw SQL makes your application harder to maintain and refactor as dependencies to your database schema creep in areas of your code that should have nothing to do with it.
public whereRaw ( string $rawWhereClause )
$rawWhereClause string The raw WHERE clause to add

with() публичный метод

array('relation1', 'relation2') Eager load relation1 and relation2 without any callbacks array('relation1' => $callable1, 'relation2' => $callable2) Eager load relation1 with callback $callable1 etc array('relation1', 'relation2' => $callable2) Eager load relation1 without a callback, relation2 with callback $callable2 The callback must have the signature function(\JDatabaseQuery $query) and doesn't return a value. It is supposed to modify the query directly. Please note that eager loaded relations produce their queries without going through the respective model. Instead they generate a SQL query directly, then map the loaded results into a DataCollection.
public with ( array $relations )
$relations array The relations to eager load. See above for more information.

Описание свойств

$_assetKey защищенное свойство

The asset key for items in this table. It's usually something in the com_example.viewname format. They asset name will be this key appended with the item's ID, e.g. com_example.viewname.123
protected string $_assetKey
Результат string

$_behaviorParams защищенное свойство

Shared parameters for behaviors
protected $_behaviorParams

$_formData защищенное свойство

The data to load into a form
protected $_formData

$_forms защищенное свойство

Array of form objects
protected $_forms

$_has_tags защищенное свойство

Does the resource support joomla tags?
protected $_has_tags

$_rules защищенное свойство

The rules associated with this record.
protected $_rules

$_trackAssets защищенное свойство

Should rows be tracked as ACL assets?
protected $_trackAssets

$aliasFields защищенное свойство

Table field name aliases, defined as aliasFieldName => actualFieldName
protected $aliasFields

$autoChecks защищенное свойство

Should I run automatic checks on the table data?
protected $autoChecks

$autoFill защищенное свойство

Should I auto-fill the fields of the model object when constructing it?
protected $autoFill

$behavioursDispatcher защищенное свойство

An event dispatcher for model behaviours
protected $behavioursDispatcher

$contentType защищенное свойство

The UCM content type (typically: com_something.viewname, e.g. com_foobar.items)
protected $contentType

$dbo защищенное свойство

The database driver for this model
protected $dbo

$eagerRelations защищенное свойство

A list of all eager loaded relations and their attached callbacks
protected $eagerRelations

$fieldsSkipChecks защищенное свойство

Which fields should be exempt from automatic checks when autoChecks is enabled
protected $fieldsSkipChecks

$fillable защищенное свойство

Which fields should be auto-filled from the model state (by extent, the request)?
protected $fillable

$formName защищенное свойство

The name of the XML form to load
protected $formName

$guarded защищенное свойство

Which fields should never be auto-filled from the model state (by extent, the request)?
protected $guarded

$idFieldName защищенное свойство

The identity field's name
protected $idFieldName

$knownFields защищенное свойство

A hash array with the table fields we know about and their information. Each key is the field name, the value is the field information
protected $knownFields

$prefixCasePermutations защищенное статическое свойство

A list of permutations of the prefix with upper/lowercase letters
protected static $prefixCasePermutations

$recordData защищенное свойство

The data of the current record
protected $recordData

$relationFilters защищенное свойство

A list of the relation filter definitions for this model
protected $relationFilters

$relationManager защищенное свойство

The relation manager of this model
protected $relationManager

$softDelete защищенное свойство

What will delete() do? True: trash (enabled set to -2); false: hard delete (remove from database)
protected $softDelete

$tableCache защищенное статическое свойство

A list of tables in the database
protected static $tableCache

$tableFieldCache защищенное статическое свойство

A list of table fields, keyed per table
protected static $tableFieldCache

$tableName защищенное свойство

The name of the database table we connect to
protected $tableName

$touches защищенное свойство

A list of the relations which will be auto-touched by save() and touch() methods
protected $touches

$whereClauses защищенное свойство

A collection of custom, additional where clauses to apply during buildQuery
protected $whereClauses