PHP 클래스 FOF30\Model\DataModel\Relation

파일 보기 프로젝트 열기: akeeba/fof 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$container The component container for this relation
$data The data loaded by this relation
$foreignKey The foreign table key for this relation
$foreignKeyMap Maps each local table key to an array of foreign table keys, used in many-to-many relations
$foreignModelClass The class name of the foreign key's model
$foreignModelComponent The application name of the foreign model
$foreignModelName The bade name of the foreign model
$localKey The local table key for this relation
$parentModel The data model we are attached to
$pivotForeignKey For many-to-many relations, the pivot table's column storing the foreign key
$pivotLocalKey For many-to-many relations, the pivot table's column storing the local key
$pivotTable For many-to-many relations, the pivot (glue) table

공개 메소드들

메소드 설명
__construct ( DataModel $parentModel, string $foreignModelName, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null ) Public constructor. Initialises the relation.
getCountSubquery ( ) : JDatabaseQuery Returns the count subquery for DataModel's has() and whereHas() methods.
getData ( callable $callback = null, Collection $dataCollection = null ) : Collection | DataModel Get the relation data.
getForeignKeyMap ( ) : array Returns the foreign key map of a many-to-many relation, used for eager loading many-to-many relations
getForeignModel ( array $config = [] ) : DataModel Gets an object instance of the foreign model
getLocalKey ( ) : string Returns the name of the local key of the relation
getNew ( ) : DataModel Returns a new item of the foreignModel type, pre-initialised to fulfil this relation
rebase ( DataModel $model ) Rebase the relation to a different model
reset ( ) Reset the relation data
saveAll ( ) Saves all related items. You can use it to touch items as well: every item being saved causes the modified_by and modified_on fields to be changed automatically, thanks to the DataModel's magic.
setDataFromCollection ( Collection &$data, mixed $keyMap = null ) : void Populates the internal $this->data collection from the contents of the provided collection. This is used by DataModel to push the eager loaded data into each item's relation.

보호된 메소드들

메소드 설명
filterForeignModel ( DataModel $foreignModel, Collection $dataCollection = null ) : boolean Applies the relation filters to the foreign model when getData is called

메소드 상세

__construct() 공개 메소드

Public constructor. Initialises the relation.
public __construct ( DataModel $parentModel, string $foreignModelName, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null )
$parentModel FOF30\Model\DataModel The data model we are attached to
$foreignModelName string The name of the foreign key's model in the format "modelName@com_something"
$localKey string The local table key for this relation
$foreignKey string The foreign key for this relation
$pivotTable string For many-to-many relations, the pivot (glue) table
$pivotLocalKey string For many-to-many relations, the pivot table's column storing the local key
$pivotForeignKey string For many-to-many relations, the pivot table's column storing the foreign key

filterForeignModel() 추상적인 보호된 메소드

Applies the relation filters to the foreign model when getData is called
abstract protected filterForeignModel ( DataModel $foreignModel, Collection $dataCollection = null ) : boolean
$foreignModel FOF30\Model\DataModel The foreign model you're operating on
$dataCollection Collection If it's an eager loaded relation, the collection of loaded parent records
리턴 boolean Return false to force an empty data collection

getCountSubquery() 추상적인 공개 메소드

Returns the count subquery for DataModel's has() and whereHas() methods.
abstract public getCountSubquery ( ) : JDatabaseQuery
리턴 JDatabaseQuery

getData() 공개 메소드

If you want to apply additional filtering to the foreign model, use the $callback. It can be any function, static method, public method or closure with an interface of function(DataModel $foreignModel). You are not supposed to return anything, just modify $foreignModel's state directly. For example, you may want to do: $foreignModel->setState('foo', 'bar')
public getData ( callable $callback = null, Collection $dataCollection = null ) : Collection | DataModel
$callback callable The callback to run on the remote model.
$dataCollection Collection
리턴 Collection | DataModel

getForeignKeyMap() 공개 메소드

Returns the foreign key map of a many-to-many relation, used for eager loading many-to-many relations
public getForeignKeyMap ( ) : array
리턴 array

getForeignModel() 공개 메소드

Gets an object instance of the foreign model
public getForeignModel ( array $config = [] ) : DataModel
$config array Optional configuration information for the Model
리턴 FOF30\Model\DataModel

getLocalKey() 공개 메소드

Returns the name of the local key of the relation
public getLocalKey ( ) : string
리턴 string

getNew() 추상적인 공개 메소드

Returns a new item of the foreignModel type, pre-initialised to fulfil this relation
abstract public getNew ( ) : DataModel
리턴 FOF30\Model\DataModel

rebase() 공개 메소드

Rebase the relation to a different model
public rebase ( DataModel $model )
$model FOF30\Model\DataModel

reset() 공개 메소드

Reset the relation data
public reset ( )

saveAll() 공개 메소드

Saves all related items. You can use it to touch items as well: every item being saved causes the modified_by and modified_on fields to be changed automatically, thanks to the DataModel's magic.
public saveAll ( )

setDataFromCollection() 공개 메소드

Populates the internal $this->data collection from the contents of the provided collection. This is used by DataModel to push the eager loaded data into each item's relation.
public setDataFromCollection ( Collection &$data, mixed $keyMap = null ) : void
$data Collection The relation data to push into this relation
$keyMap mixed Used by many-to-many relations to pass around the local to foreign key map
리턴 void

프로퍼티 상세

$container 보호되어 있는 프로퍼티

The component container for this relation
protected $container

$data 보호되어 있는 프로퍼티

The data loaded by this relation
protected $data

$foreignKey 보호되어 있는 프로퍼티

The foreign table key for this relation
protected $foreignKey

$foreignKeyMap 보호되어 있는 프로퍼티

Maps each local table key to an array of foreign table keys, used in many-to-many relations
protected $foreignKeyMap

$foreignModelClass 보호되어 있는 프로퍼티

The class name of the foreign key's model
protected $foreignModelClass

$foreignModelComponent 보호되어 있는 프로퍼티

The application name of the foreign model
protected $foreignModelComponent

$foreignModelName 보호되어 있는 프로퍼티

The bade name of the foreign model
protected $foreignModelName

$localKey 보호되어 있는 프로퍼티

The local table key for this relation
protected $localKey

$parentModel 보호되어 있는 프로퍼티

The data model we are attached to
protected $parentModel

$pivotForeignKey 보호되어 있는 프로퍼티

For many-to-many relations, the pivot table's column storing the foreign key
protected $pivotForeignKey

$pivotLocalKey 보호되어 있는 프로퍼티

For many-to-many relations, the pivot table's column storing the local key
protected $pivotLocalKey

$pivotTable 보호되어 있는 프로퍼티

For many-to-many relations, the pivot (glue) table
protected $pivotTable