Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Items Class Reference
Inheritance diagram for Items:
Template Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Backend\Block\Template\Context $context, \Magento\GiftMessage\Helper\Message $messageHelper, array $data=[])
 
 getItem ()
 
 getDefaultSender ()
 
 getDefaultRecipient ()
 
 getFieldName ($name)
 
 getFieldId ($id)
 
 getFieldIdPrefix ()
 
 getMessage ()
 
 getSaveUrl ()
 
 getHtmlId ()
 
 canDisplayGiftmessage ()
 
 getSender ()
 
 getRecipient ()
 
 getMessageText ()
 
- Public Member Functions inherited from Template
 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getFormKey ()
 
 isOutputEnabled ($moduleName=null)
 
 getAuthorization ()
 
 getToolbar ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- 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)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Protected Member Functions

 _initMessage ()
 
- Protected Member Functions inherited from Template
 _toHtml ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_giftMessage = []
 
 $_messageHelper
 
- Protected Attributes inherited from Template
 $_authorization
 
 $mathRandom
 
 $_backendSession
 
 $formKey
 
 $nameBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Gift message adminhtml sales order view items

@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 15 of file Items.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Template\Context  $context,
\Magento\GiftMessage\Helper\Message  $messageHelper,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Template\Context$context
\Magento\GiftMessage\Helper\Message$messageHelper
array$data

Definition at line 34 of file Items.php.

38  {
39  $this->_messageHelper = $messageHelper;
40  parent::__construct($context, $data);
41  }

Member Function Documentation

◆ _initMessage()

_initMessage ( )
protected

Initialize gift message for entity

Returns
$this

Definition at line 140 of file Items.php.

141  {
142  $this->_giftMessage[$this->getItem()->getGiftMessageId()] = $this->_messageHelper->getGiftMessage(
143  $this->getItem()->getGiftMessageId()
144  );
145 
146  // init default values for giftmessage form
147  if (!$this->getMessage()->getSender()) {
148  $this->getMessage()->setSender($this->getDefaultSender());
149  }
150  if (!$this->getMessage()->getRecipient()) {
151  $this->getMessage()->setRecipient($this->getDefaultRecipient());
152  }
153 
154  return $this;
155  }

◆ canDisplayGiftmessage()

canDisplayGiftmessage ( )

Indicates that block can display giftmessages form

Returns
boolean

Definition at line 201 of file Items.php.

202  {
203  return $this->getItem()->getGiftMessageId();
204  }

◆ getDefaultRecipient()

getDefaultRecipient ( )

Retrieve default value for giftmessage recipient

Returns
string

Definition at line 77 of file Items.php.

78  {
79  if (!$this->getItem()) {
80  return '';
81  }
82 
83  if ($this->getItem()->getOrder()) {
84  if ($this->getItem()->getOrder()->getShippingAddress()) {
85  return $this->getItem()->getOrder()->getShippingAddress()->getName();
86  } elseif ($this->getItem()->getOrder()->getBillingAddress()) {
87  return $this->getItem()->getOrder()->getBillingAddress()->getName();
88  }
89  }
90 
91  if ($this->getItem()->getShippingAddress()) {
92  return $this->getItem()->getShippingAddress()->getName();
93  } elseif ($this->getItem()->getBillingAddress()) {
94  return $this->getItem()->getBillingAddress()->getName();
95  }
96 
97  return '';
98  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ getDefaultSender()

getDefaultSender ( )

Retrieve default value for giftmessage sender

Returns
string

Definition at line 59 of file Items.php.

60  {
61  if (!$this->getItem()) {
62  return '';
63  }
64 
65  if ($this->getItem()->getOrder()) {
66  return $this->getItem()->getOrder()->getBillingAddress()->getName();
67  }
68 
69  return $this->getItem()->getBillingAddress()->getName();
70  }

◆ getFieldId()

getFieldId (   $id)

Retrieve real html id for field

Parameters
string$id
Returns
string @codeCoverageIgnore

Definition at line 119 of file Items.php.

120  {
121  return $this->getFieldIdPrefix() . $id;
122  }
$id
Definition: fieldset.phtml:14

◆ getFieldIdPrefix()

getFieldIdPrefix ( )

Retrieve field html id prefix

Returns
string @codeCoverageIgnore

Definition at line 130 of file Items.php.

131  {
132  return 'giftmessage_' . $this->getItem()->getId() . '_';
133  }

◆ getFieldName()

getFieldName (   $name)

Retrieve real name for field

Parameters
string$name
Returns
string @codeCoverageIgnore

Definition at line 107 of file Items.php.

108  {
109  return 'giftmessage[' . $this->getItem()->getId() . '][' . $name . ']';
110  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getHtmlId()

getHtmlId ( )

Retrieve block html id

Returns
string @codeCoverageIgnore

Definition at line 191 of file Items.php.

192  {
193  return substr($this->getFieldIdPrefix(), 0, -1);
194  }

◆ getItem()

getItem ( )

Get Order Item

Returns
\Magento\Sales\Model\Order\Item @codeCoverageIgnore

Definition at line 49 of file Items.php.

50  {
51  return $this->getParentBlock()->getItem();
52  }

◆ getMessage()

getMessage ( )

Retrieve gift message for entity

Returns
\Magento\GiftMessage\Model\Message

Definition at line 162 of file Items.php.

163  {
164  if (!isset($this->_giftMessage[$this->getItem()->getGiftMessageId()])) {
165  $this->_initMessage();
166  }
167 
168  return $this->_giftMessage[$this->getItem()->getGiftMessageId()];
169  }

◆ getMessageText()

getMessageText ( )

Retrieve gift message text

Returns
string

Definition at line 231 of file Items.php.

232  {
233  return $this->escapeHtml($this->getMessage()->getMessage());
234  }

◆ getRecipient()

getRecipient ( )

Retrieve gift message recipient

Returns
string

Definition at line 221 of file Items.php.

◆ getSaveUrl()

getSaveUrl ( )

Retrieve save url

Returns
array @codeCoverageIgnore

Definition at line 177 of file Items.php.

178  {
179  return $this->getUrl(
180  'sales/order_view_giftmessage/save',
181  ['entity' => $this->getItem()->getId(), 'type' => 'order_item', 'reload' => true]
182  );
183  }

◆ getSender()

getSender ( )

Retrieve gift message sender

Returns
string

Definition at line 211 of file Items.php.

Field Documentation

◆ $_giftMessage

$_giftMessage = []
protected

Definition at line 22 of file Items.php.

◆ $_messageHelper

$_messageHelper
protected

Definition at line 27 of file Items.php.


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