Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Address Class Reference
Inheritance diagram for Address:
AbstractEntity AbstractEntity AbstractResource EntityInterface ProviderInterface SubResourceModelAddress

Public Member Functions

 __construct (\Magento\Eav\Model\Entity\Context $context, \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite, \Magento\Framework\Validator\Factory $validatorFactory, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, $data=[])
 
 getEntityType ()
 
 delete ($object)
 
- Public Member Functions inherited from AbstractEntity
 __construct (\Magento\Eav\Model\Entity\Context $context, \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite, $data=[])
 
 save (\Magento\Framework\Model\AbstractModel $object)
 
- Public Member Functions inherited from AbstractEntity
 __construct (Context $context, $data=[])
 
 setConnection ($connection)
 
 getConnection ()
 
 getIdFieldName ()
 
 getTable ($alias)
 
 setType ($type)
 
 getEntityType ()
 
 getType ()
 
 getTypeId ()
 
 unsetAttributes ($attributes=null)
 
 addAttribute (AbstractAttribute $attribute, $object=null)
 
 isPartialLoad ($flag=null)
 
 isPartialSave ($flag=null)
 
 loadAllAttributes ($object=null)
 
 getSortedAttributes ($setId=null)
 
 attributesCompare ($firstAttribute, $secondAttribute)
 
 getAttributesByCode ()
 
 getAttributesByTable ()
 
 getEntityTable ()
 
 getLinkField ()
 
 getEntityIdField ()
 
 getValueEntityIdField ()
 
 getValueTablePrefix ()
 
 getEntityTablePrefix ()
 
 isAttributeStatic ($attribute)
 
 validate ($object)
 
 setNewIncrementId (DataObject $object)
 
 checkAttributeUniqueValue (AbstractAttribute $attribute, $object)
 
 getDefaultAttributeSourceModel ()
 
 load ($object, $entityId, $attributes=[])
 
 save (\Magento\Framework\Model\AbstractModel $object)
 
 saveAttribute (DataObject $object, $attributeCode)
 
 delete ($object)
 
 getDefaultAttributes ()
 
 afterLoad (DataObject $object)
 
 beforeSave (DataObject $object)
 
 afterSave (DataObject $object)
 
 beforeDelete (DataObject $object)
 
 afterDelete (DataObject $object)
 
- Public Member Functions inherited from AbstractResource
 __construct ()
 
 getConnection ()
 
 beginTransaction ()
 
 addCommitCallback ($callback)
 
 commit ()
 
 rollBack ()
 
 getValidationRulesBeforeSave ()
 

Protected Member Functions

 _construct ()
 
 _beforeSave (\Magento\Framework\DataObject $address)
 
 _validate ($address)
 
 _afterDelete (\Magento\Framework\DataObject $address)
 
- Protected Member Functions inherited from AbstractEntity
 _afterLoad (\Magento\Framework\DataObject $object)
 
 isModified (\Magento\Framework\Model\AbstractModel $object)
 
- Protected Member Functions inherited from AbstractEntity
 _construct ()
 
 _getConfig ()
 
 _isApplicableAttribute ($object, $attribute)
 
 _isCallableAttributeInstance ($instance, $method, $args)
 
 loadAttributesMetadata ($attributes)
 
 _loadModelAttributes ($object)
 
 _prepareLoadSelect (array $selects)
 
 _getLoadRowSelect ($object, $rowId)
 
 _getLoadAttributesSelect ($object, $table)
 
 _setAttributeValue ($object, $valueRow)
 
 processSave ($object)
 
 _getOrigObject ($object)
 
 _collectSaveData ($newObject)
 
 _canUpdateAttribute (AbstractAttribute $attribute, $v, array &$origData)
 
 _getStaticFieldProperties ($field)
 
 _prepareStaticValue ($key, $value)
 
 _insertAttribute ($object, $attribute, $value)
 
 _updateAttribute ($object, $attribute, $valueId, $value)
 
 _saveAttribute ($object, $attribute, $value)
 
 _processAttributeValues ()
 
 _prepareValueForSave ($value, AbstractAttribute $attribute)
 
 _deleteAttributes ($object, $table, $info)
 
 getAttributeRow ($entity, $object, $attribute)
 
 evaluateDelete ($object, $id, $connection)
 
 _afterLoad (DataObject $object)
 
 _beforeSave (DataObject $object)
 
 _afterSave (DataObject $object)
 
 _beforeDelete (DataObject $object)
 
 _afterDelete (DataObject $object)
 
 _getDefaultAttributeModel ()
 
 _getDefaultAttributes ()
 
 _isAttributeValueEmpty (AbstractAttribute $attribute, $value)
 
 getAttributeLoader ()
 
 loadAttributesForObject ($attributes, $object=null)
 
- Protected Member Functions inherited from AbstractResource
 _construct ()
 
 _serializeField (DataObject $object, $field, $defaultValue=null, $unsetEmpty=false)
 
 _unserializeField (DataObject $object, $field, $defaultValue=null)
 
 _prepareDataForTable (DataObject $object, $table)
 
 _prepareTableValueForSave ($value, $type)
 
 _getColumnsForEntityLoad (\Magento\Framework\Model\AbstractModel $object, $tableName)
 
 getSerializer ()
 

Protected Attributes

 $_validatorFactory
 
 $customerRepository
 
- Protected Attributes inherited from AbstractEntity
 $entitySnapshot
 
 $entityRelationComposite
 
- Protected Attributes inherited from AbstractEntity
 $attributeLoader
 
 $connectionName
 
 $_type
 
 $_attributesByCode = []
 
 $_attributesByTable = []
 
 $_staticAttributes = []
 
 $_entityTable
 
 $_describeTable = []
 
 $_entityIdField
 
 $linkIdField
 
 $_valueEntityIdField
 
 $_valueTablePrefix
 
 $_entityTablePrefix
 
 $_isPartialLoad = false
 
 $_isPartialSave = false
 
 $_sortingSetId = null
 
 $_attributeValuesToDelete = []
 
 $_attributeValuesToSave = []
 
 $_resource
 
 $_eavConfig
 
 $_attrSetEntity
 
 $_localeFormat
 
 $_resourceHelper
 
 $_universalFactory
 
 $transactionManager
 
 $objectRelationProcessor
 
- Protected Attributes inherited from AbstractResource
 $serializer
 
 $_logger
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractEntity
static $_attributeBackendTables = []
 

Detailed Description

Definition at line 20 of file Address.php.

Constructor & Destructor Documentation

◆ __construct()

Parameters
\Magento\Eav\Model\Entity\Context$context
\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot$entitySnapshot

Definition at line 40 of file Address.php.

47  {
48  $this->customerRepository = $customerRepository;
49  $this->_validatorFactory = $validatorFactory;
50  parent::__construct($context, $entitySnapshot, $entityRelationComposite, $data);
51  }

Member Function Documentation

◆ _afterDelete()

_afterDelete ( \Magento\Framework\DataObject  $address)
protected
Parameters
\Magento\Customer\Model\Address$address
Returns
$this

Definition at line 144 of file Address.php.

145  {
146  $customer = $this->getCustomerRegistry()->retrieve($address->getCustomerId());
147 
148  $this->getDeleteRelation()->deleteRelation($address, $customer);
149  return parent::_afterDelete($address);
150  }
$customer
Definition: customers.php:11
$address
Definition: customer.php:38

◆ _beforeSave()

_beforeSave ( \Magento\Framework\DataObject  $address)
protected

Check customer address before saving

Parameters
\Magento\Framework\DataObject$address
Returns
$this

Definition at line 83 of file Address.php.

84  {
85  parent::_beforeSave($address);
86 
87  $this->_validate($address);
88 
89  return $this;
90  }
$address
Definition: customer.php:38

◆ _construct()

_construct ( )
protected

Resource initialization.

Returns
void

Definition at line 58 of file Address.php.

59  {
60  $this->connectionName = 'customer';
61  }

◆ _validate()

_validate (   $address)
protected

Validate customer address entity

Parameters
\Magento\Framework\DataObject$address
Returns
void
Exceptions

Definition at line 99 of file Address.php.

100  {
101  $validator = $this->_validatorFactory->createValidator('customer_address', 'save');
102 
103  if (!$validator->isValid($address)) {
104  throw new \Magento\Framework\Validator\Exception(
105  null,
106  null,
107  $validator->getMessages()
108  );
109  }
110  }
$address
Definition: customer.php:38

◆ delete()

delete (   $object)

{}

Definition at line 115 of file Address.php.

116  {
117  $result = parent::delete($object);
118  $object->setData([]);
119  return $result;
120  }

◆ getEntityType()

getEntityType ( )

Getter and lazy loader for _type

Exceptions

Definition at line 69 of file Address.php.

70  {
71  if (empty($this->_type)) {
72  $this->setType('customer_address');
73  }
74  return parent::getEntityType();
75  }

Field Documentation

◆ $_validatorFactory

$_validatorFactory
protected

Definition at line 25 of file Address.php.

◆ $customerRepository

$customerRepository
protected

Definition at line 30 of file Address.php.


The documentation for this class was generated from the following file: