PHP 클래스 FOF30\Model\DataModel

Type hinting -- start
상속: extends Model, implements JTableInterface
파일 보기 프로젝트 열기: akeeba/fof 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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