Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[]) | |
__sleep () | |
__wakeup () | |
setIdFieldName ($name) | |
getIdFieldName () | |
getId () | |
setId ($value) | |
isDeleted ($isDeleted=null) | |
hasDataChanges () | |
setData ($key, $value=null) | |
unsetData ($key=null) | |
setDataChanges ($value) | |
getOrigData ($key=null) | |
setOrigData ($key=null, $data=null) | |
dataHasChangedFor ($field) | |
getResourceName () | |
getResourceCollection () | |
getCollection () | |
load ($modelId, $field=null) | |
beforeLoad ($identifier, $field=null) | |
afterLoad () | |
isSaveAllowed () | |
setHasDataChanges ($flag) | |
save () | |
afterCommitCallback () | |
isObjectNew ($flag=null) | |
beforeSave () | |
validateBeforeSave () | |
getCacheTags () | |
cleanModelCache () | |
afterSave () | |
delete () | |
beforeDelete () | |
afterDelete () | |
afterDeleteCommit () | |
getResource () | |
getEntityId () | |
setEntityId ($entityId) | |
clearInstance () | |
getStoredData () | |
getEventPrefix () | |
![]() | |
__construct (array $data=[]) | |
addData (array $arr) | |
setData ($key, $value=null) | |
unsetData ($key=null) | |
getData ($key='', $index=null) | |
getDataByPath ($path) | |
getDataByKey ($key) | |
setDataUsingMethod ($key, $args=[]) | |
getDataUsingMethod ($key, $args=null) | |
hasData ($key='') | |
toArray (array $keys=[]) | |
convertToArray (array $keys=[]) | |
toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
toJson (array $keys=[]) | |
convertToJson (array $keys=[]) | |
toString ($format='') | |
__call ($method, $args) | |
isEmpty () | |
serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"') | |
debug ($data=null, &$objects=[]) | |
offsetSet ($offset, $value) | |
offsetExists ($offset) | |
offsetUnset ($offset) | |
offsetGet ($offset) | |
Protected Member Functions | |
_construct () | |
_init ($resourceModel) | |
_setResourceModel ($resourceName, $collectionName=null) | |
_getResource () | |
_getEventData () | |
_beforeLoad ($modelId, $field=null) | |
_afterLoad () | |
_hasModelChanged () | |
_getValidatorBeforeSave () | |
_createValidatorBeforeSave () | |
_getValidationRulesBeforeSave () | |
_clearReferences () | |
_clearData () | |
![]() | |
_getData ($key) | |
_underscore ($name) | |
Protected Attributes | |
$_eventPrefix = 'core_abstract' | |
$_eventObject = 'object' | |
$_idFieldName = 'id' | |
$_hasDataChanges = false | |
$_origData | |
$_isDeleted = false | |
$_resource | |
$_resourceCollection | |
$_resourceName | |
$_collectionName | |
$_cacheTag = false | |
$_dataSaveAllowed = true | |
$_isObjectNew = null | |
$_validatorBeforeSave = null | |
$_eventManager | |
$_cacheManager | |
$_registry | |
$_logger | |
$_appState | |
$_actionValidator | |
$storedData = [] | |
![]() | |
$_data = [] | |
Additional Inherited Members | |
![]() | |
static | $_underscoreCache = [] |
Abstract model class
@api @SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.NumberOfChildren) @SuppressWarnings(PHPMD.TooManyFields)
Definition at line 19 of file AbstractModel.php.
__construct | ( | \Magento\Framework\Model\Context | $context, |
\Magento\Framework\Registry | $registry, | ||
\Magento\Framework\Model\ResourceModel\AbstractResource | $resource = null , |
||
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection = null , |
||
array | $data = [] |
||
) |
\Magento\Framework\Model\Context | $context | |
\Magento\Framework\Registry | $registry | |
\Magento\Framework\Model\ResourceModel\AbstractResource | $resource | |
\Magento\Framework\Data\Collection\AbstractDb | $resourceCollection | |
array | $data |
Definition at line 172 of file AbstractModel.php.
__sleep | ( | ) |
__wakeup | ( | ) |
Init not serializable fields
Definition at line 246 of file AbstractModel.php.
|
protected |
|
protected |
Processing object before load data
int | $modelId | |
null | string | $field |
Definition at line 561 of file AbstractModel.php.
|
protected |
|
protected |
|
protected |
Model construct that should be used for object initialization
Definition at line 203 of file AbstractModel.php.
|
protected |
Creates validator for the model with all validation rules in it. Returns FALSE, if no validation rules exist.
Definition at line 741 of file AbstractModel.php.
|
protected |
Get array of objects transferred to default events processing
Definition at line 546 of file AbstractModel.php.
|
protected |
Get resource instance
Definition at line 470 of file AbstractModel.php.
|
protected |
Template method to return validate rules for the entity
Definition at line 767 of file AbstractModel.php.
|
protected |
Returns validator, which contains all rules to validate this model. Returns FALSE, if no validation rules exist.
Definition at line 727 of file AbstractModel.php.
|
protected |
Check whether model has changed data. Can be overloaded in child classes to perform advanced check whether model needs to be saved e.g. using resourceModel->hasDataChanged() or any other technique
Definition at line 614 of file AbstractModel.php.
|
protected |
Standard model initialization
string | $resourceModel |
Definition at line 213 of file AbstractModel.php.
|
protected |
Set resource names
If collection name is omitted, resource name will be used with _collection appended
string | $resourceName | |
string | null | $collectionName |
Definition at line 454 of file AbstractModel.php.
afterCommitCallback | ( | ) |
Callback function which called after transaction commit in resource model
Definition at line 657 of file AbstractModel.php.
afterDelete | ( | ) |
afterDeleteCommit | ( | ) |
Processing manipulation after main transaction commit
Definition at line 878 of file AbstractModel.php.
afterLoad | ( | ) |
Object after load processing. Implemented as public interface for supporting objects after load in collections
Definition at line 600 of file AbstractModel.php.
afterSave | ( | ) |
Processing object after save data
Definition at line 814 of file AbstractModel.php.
beforeDelete | ( | ) |
Processing object before delete data
Definition at line 845 of file AbstractModel.php.
beforeLoad | ( | $identifier, | |
$field = null |
|||
) |
Process operation before object load
string | $identifier | |
string | null | $field |
Definition at line 590 of file AbstractModel.php.
beforeSave | ( | ) |
Processing object before save data
Definition at line 689 of file AbstractModel.php.
cleanModelCache | ( | ) |
clearInstance | ( | ) |
Clearing object for correct deleting by garbage collector
Definition at line 922 of file AbstractModel.php.
dataHasChangedFor | ( | $field | ) |
Compare object data with original data
string | $field |
Definition at line 438 of file AbstractModel.php.
delete | ( | ) |
Delete object from database
Definition at line 833 of file AbstractModel.php.
getCacheTags | ( | ) |
Get list of cache tags applied to model object. Return false if cache tags are not supported by model
Definition at line 778 of file AbstractModel.php.
getCollection | ( | ) |
Retrieve collection instance
@TODO MAGETWO-23541: Incorrect dependencies between Model\AbstractModel and Data\Collection\Db from Framework
Definition at line 520 of file AbstractModel.php.
getEntityId | ( | ) |
getEventPrefix | ( | ) |
getId | ( | ) |
getIdFieldName | ( | ) |
getOrigData | ( | $key = null | ) |
Get object original data
string | $key |
Definition at line 402 of file AbstractModel.php.
getResource | ( | ) |
Retrieve model resource
Definition at line 891 of file AbstractModel.php.
getResourceCollection | ( | ) |
Get collection instance
@TODO MAGETWO-23541: Incorrect dependencies between Model\AbstractModel and Data\Collection\Db from Framework
Definition at line 499 of file AbstractModel.php.
getResourceName | ( | ) |
getStoredData | ( | ) |
hasDataChanges | ( | ) |
Check if initial object data was changed.
Initial data is coming to object constructor. Flag value should be set up to true after any external data changes
Definition at line 328 of file AbstractModel.php.
isDeleted | ( | $isDeleted = null | ) |
Set _isDeleted flag value (if $isDeleted parameter is defined) and return current flag value
boolean | $isDeleted |
Definition at line 311 of file AbstractModel.php.
isObjectNew | ( | $flag = null | ) |
Check object state (true - if it is object without id on object just created) This method can help detect if object just created in _afterSave method problem is what in after save object has id and we can't detect what object was created in this transaction
bool | null | $flag |
Definition at line 673 of file AbstractModel.php.
isSaveAllowed | ( | ) |
Definition at line 622 of file AbstractModel.php.
load | ( | $modelId, | |
$field = null |
|||
) |
Load object data
integer | $modelId | |
null | string | $field |
Definition at line 535 of file AbstractModel.php.
save | ( | ) |
setData | ( | $key, | |
$value = null |
|||
) |
Overwrite data in the object.
The $key parameter can be string or array. If $key is string, the attribute value will be overwritten by $value
If $key is an array, it will overwrite all the data in the object.
string | array | $key | |
mixed | $value |
Definition at line 345 of file AbstractModel.php.
setDataChanges | ( | $value | ) |
Clears data changes status
bool | $value |
Definition at line 390 of file AbstractModel.php.
setEntityId | ( | $entityId | ) |
Set entity id
int | $entityId |
Definition at line 912 of file AbstractModel.php.
setHasDataChanges | ( | $flag | ) |
setId | ( | $value | ) |
Identifier setter
mixed | $value |
Definition at line 299 of file AbstractModel.php.
setIdFieldName | ( | $name | ) |
Id field name setter
string | $name |
Definition at line 267 of file AbstractModel.php.
setOrigData | ( | $key = null , |
|
$data = null |
|||
) |
Initialize object original data
@FIXME changing original data can't be available as public interface
string | $key | |
mixed | $data |
Definition at line 422 of file AbstractModel.php.
unsetData | ( | $key = null | ) |
Unset data from the object.
null | string | array | $key |
Definition at line 367 of file AbstractModel.php.
validateBeforeSave | ( | ) |
Validate model before saving it
Definition at line 705 of file AbstractModel.php.
|
protected |
Definition at line 156 of file AbstractModel.php.
|
protected |
Definition at line 151 of file AbstractModel.php.
|
protected |
Definition at line 136 of file AbstractModel.php.
|
protected |
Definition at line 99 of file AbstractModel.php.
|
protected |
Definition at line 90 of file AbstractModel.php.
|
protected |
Definition at line 108 of file AbstractModel.php.
|
protected |
Definition at line 129 of file AbstractModel.php.
|
protected |
Definition at line 35 of file AbstractModel.php.
|
protected |
Definition at line 26 of file AbstractModel.php.
|
protected |
Definition at line 48 of file AbstractModel.php.
|
protected |
Definition at line 42 of file AbstractModel.php.
|
protected |
Definition at line 62 of file AbstractModel.php.
|
protected |
Definition at line 115 of file AbstractModel.php.
|
protected |
Definition at line 146 of file AbstractModel.php.
|
protected |
Definition at line 55 of file AbstractModel.php.
|
protected |
Definition at line 141 of file AbstractModel.php.
|
protected |
Definition at line 69 of file AbstractModel.php.
|
protected |
Definition at line 76 of file AbstractModel.php.
|
protected |
Definition at line 83 of file AbstractModel.php.
|
protected |
Definition at line 122 of file AbstractModel.php.
|
protected |
Definition at line 163 of file AbstractModel.php.