Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Message Class Reference
Inheritance diagram for Message:
AbstractExtensibleModel MessageInterface AbstractModel CustomAttributesDataInterface ExtensibleDataInterface DataObject ExtensibleDataInterface

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\GiftMessage\Model\TypeFactory $typeFactory, \Magento\GiftMessage\Model\ResourceModel\Message $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getEntityModelByType ($type)
 
 isMessageEmpty ()
 
 getGiftMessageId ()
 
 setGiftMessageId ($id)
 
 getCustomerId ()
 
 setCustomerId ($id)
 
 getSender ()
 
 setSender ($sender)
 
 getRecipient ()
 
 setRecipient ($recipient)
 
 getMessage ()
 
 setMessage ($message)
 
 getExtensionAttributes ()
 
 setExtensionAttributes (\Magento\GiftMessage\Api\Data\MessageExtensionInterface $extensionAttributes)
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __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 ()
 
- Public Member Functions inherited from DataObject
 __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 ()
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_typeFactory
 
- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_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 = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 
- Data Fields inherited from MessageInterface
const GIFT_MESSAGE_ID = 'gift_message_id'
 
const CUSTOMER_ID = 'customer_id'
 
const SENDER = 'sender'
 
const RECIPIENT = 'recipient'
 
const MESSAGE = 'message'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Gift Message model

@api

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m
Since
100.0.2

Definition at line 17 of file Message.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Framework\Api\ExtensionAttributesFactory  $extensionFactory,
AttributeValueFactory  $customAttributeFactory,
\Magento\GiftMessage\Model\TypeFactory  $typeFactory,
\Magento\GiftMessage\Model\ResourceModel\Message  $resource = null,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [] 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Api\ExtensionAttributesFactory$extensionFactory
AttributeValueFactory$customAttributeFactory
TypeFactory$typeFactory
\Magento\GiftMessage\Model\ResourceModel\Message$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data

Definition at line 35 of file Message.php.

44  {
45  $this->_typeFactory = $typeFactory;
46  parent::__construct(
47  $context,
48  $registry,
49  $extensionFactory,
51  $resource,
52  $resourceCollection,
53  $data
54  );
55  }
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _construct()

_construct ( )
protected
Returns
void

Definition at line 60 of file Message.php.

61  {
62  $this->_init(\Magento\GiftMessage\Model\ResourceModel\Message::class);
63  }

◆ getCustomerId()

getCustomerId ( )

{Return the customer ID.

Returns
int|null Customer ID. Otherwise, null.
}

Implements MessageInterface.

Definition at line 107 of file Message.php.

108  {
109  return $this->getData(self::CUSTOMER_ID);
110  }

◆ getEntityModelByType()

getEntityModelByType (   $type)

Return model from entity type

Parameters
string$type
Returns
mixed

Definition at line 71 of file Message.php.

72  {
73  return $this->_typeFactory->createType($type);
74  }
$type
Definition: item.phtml:13

◆ getExtensionAttributes()

getExtensionAttributes ( )

Retrieve existing extension attributes object or create a new one.

Returns
\Magento\GiftMessage\Api\Data\MessageExtensionInterface|null

Implements MessageInterface.

Definition at line 173 of file Message.php.

◆ getGiftMessageId()

getGiftMessageId ( )

{#- Return the gift message ID.

Returns
int|null Gift message ID. Otherwise, null.
}

Implements MessageInterface.

Definition at line 91 of file Message.php.

92  {
93  return $this->getData(self::GIFT_MESSAGE_ID);
94  }

◆ getMessage()

getMessage ( )

{Return the message text.

Returns
string Message text.
}

Implements MessageInterface.

Definition at line 155 of file Message.php.

156  {
157  return $this->getData(self::MESSAGE);
158  }

◆ getRecipient()

getRecipient ( )

{Return the recipient name.

Returns
string Recipient name.
}

Implements MessageInterface.

Definition at line 139 of file Message.php.

140  {
141  return $this->getData(self::RECIPIENT);
142  }

◆ getSender()

getSender ( )

{Return the sender name.

Returns
string Sender name.
}

Implements MessageInterface.

Definition at line 123 of file Message.php.

124  {
125  return $this->getData(self::SENDER);
126  }

◆ isMessageEmpty()

isMessageEmpty ( )

Checks if the gift message is empty

Returns
bool

Definition at line 81 of file Message.php.

82  {
83  return trim($this->getMessage()) == '';
84  }

◆ setCustomerId()

setCustomerId (   $id)

{Set the customer ID.

Parameters
int | null$id
Returns
$this
}

Implements MessageInterface.

Definition at line 115 of file Message.php.

116  {
117  return $this->setData(self::CUSTOMER_ID, $id);
118  }
$id
Definition: fieldset.phtml:14

◆ setExtensionAttributes()

setExtensionAttributes ( \Magento\GiftMessage\Api\Data\MessageExtensionInterface  $extensionAttributes)

Set an extension attributes object.

Parameters
\Magento\GiftMessage\Api\Data\MessageExtensionInterface$extensionAttributes
Returns
$this

Implements MessageInterface.

Definition at line 184 of file Message.php.

185  {
187  }
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)

◆ setGiftMessageId()

setGiftMessageId (   $id)

{Set the gift message ID.

Parameters
int | null$id
Returns
$this
}

Implements MessageInterface.

Definition at line 99 of file Message.php.

100  {
101  return $this->setData(self::GIFT_MESSAGE_ID, $id);
102  }
$id
Definition: fieldset.phtml:14

◆ setMessage()

setMessage (   $message)

{Set the message text.

Parameters
string$message
Returns
$this
}

Implements MessageInterface.

Definition at line 163 of file Message.php.

164  {
165  return $this->setData(self::MESSAGE, $message);
166  }
$message

◆ setRecipient()

setRecipient (   $recipient)

{Get the recipient name.

Parameters
string$recipient
Returns
$this
}

Implements MessageInterface.

Definition at line 147 of file Message.php.

148  {
149  return $this->setData(self::RECIPIENT, $recipient);
150  }

◆ setSender()

setSender (   $sender)

{Set the sender name.

Parameters
string$sender
Returns
$this
}

Implements MessageInterface.

Definition at line 131 of file Message.php.

132  {
133  return $this->setData(self::SENDER, $sender);
134  }

Field Documentation

◆ $_typeFactory

$_typeFactory
protected

Definition at line 23 of file Message.php.


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