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

Public Member Functions

 __construct (\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\SendFriend\Helper\Data $sendfriendData, \Magento\Framework\Registry $registry, \Magento\Customer\Helper\View $customerViewHelper, \Magento\Framework\App\Http\Context $httpContext, \Magento\SendFriend\Model\SendFriend $sendfriend, array $data=[])
 
 getUserName ()
 
 getEmail ()
 
 getMessage ()
 
 getFormData ()
 
 setFormData ($data)
 
 getProductId ()
 
 getCategoryId ()
 
 getMaxRecipients ()
 
 getSendUrl ()
 
 canSend ()
 
- 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 Attributes

 $_sendfriendData = null
 
 $_coreRegistry = null
 
 $_customerSession
 
 $httpContext
 
 $_customerViewHelper
 
 $sendfriend
 
- 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_'
 
- 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)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Email to a Friend Block

@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 Send.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Template\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
\Magento\SendFriend\Helper\Data  $sendfriendData,
\Magento\Framework\Registry  $registry,
\Magento\Customer\Helper\View  $customerViewHelper,
\Magento\Framework\App\Http\Context  $httpContext,
\Magento\SendFriend\Model\SendFriend  $sendfriend,
array  $data = [] 
)
Parameters
\Magento\Framework\View\Element\Template\Context$context
\Magento\Customer\Model\Session$customerSession
\Magento\SendFriend\Helper\Data$sendfriendData
\Magento\Framework\Registry$registry
\Magento\Customer\Helper\View$customerViewHelper
\Magento\Framework\App\Http\Context$httpContext
\Magento\SendFriend\Model\SendFriend$sendfriend
array$data

Definition at line 63 of file Send.php.

72  {
73  $this->_customerSession = $customerSession;
74  $this->_coreRegistry = $registry;
75  $this->_sendfriendData = $sendfriendData;
76  $this->sendfriend = $sendfriend;
77  parent::__construct($context, $data);
78  $this->_isScopePrivate = true;
79  $this->httpContext = $httpContext;
80  $this->_customerViewHelper = $customerViewHelper;
81  }

Member Function Documentation

◆ canSend()

canSend ( )

Check if user is allowed to send

Returns
boolean

Definition at line 221 of file Send.php.

222  {
223  return !$this->sendfriend->isExceedLimit();
224  }

◆ getCategoryId()

getCategoryId ( )

Retrieve current category id for product

Returns
int

Definition at line 185 of file Send.php.

186  {
187  return $this->getRequest()->getParam('cat_id', null);
188  }

◆ getEmail()

getEmail ( )

Retrieve sender email address

Returns
string

Definition at line 112 of file Send.php.

113  {
114  $email = $this->getFormData()->getData('sender/email');
115  if (!empty($email)) {
116  return trim($email);
117  }
118 
119  /* @var $session \Magento\Customer\Model\Session */
121 
122  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
123  return $session->getCustomerDataObject()->getEmail();
124  }
125 
126  return '';
127  }
$email
Definition: details.phtml:13

◆ getFormData()

getFormData ( )

Retrieve Form data or empty \Magento\Framework\DataObject

Returns
\Magento\Framework\DataObject

Definition at line 144 of file Send.php.

145  {
146  $data = $this->getData('form_data');
147  if (!$data instanceof \Magento\Framework\DataObject) {
148  $data = new \Magento\Framework\DataObject();
149  $this->setData('form_data', $data);
150  }
151 
152  return $data;
153  }
getData($key='', $index=null)
Definition: DataObject.php:119
setData($key, $value=null)
Definition: DataObject.php:72

◆ getMaxRecipients()

getMaxRecipients ( )

Retrieve Max Recipients

Returns
int

Definition at line 195 of file Send.php.

196  {
197  return $this->_sendfriendData->getMaxRecipients();
198  }

◆ getMessage()

getMessage ( )

Retrieve Message text

Returns
string

Definition at line 134 of file Send.php.

135  {
136  return $this->getFormData()->getData('sender/message');
137  }

◆ getProductId()

getProductId ( )

Retrieve Current Product Id

Returns
int

Definition at line 175 of file Send.php.

176  {
177  return $this->getRequest()->getParam('id', null);
178  }

◆ getSendUrl()

getSendUrl ( )

Retrieve Send URL for Form Action

Returns
string

Definition at line 205 of file Send.php.

206  {
207  return $this->getUrl(
208  'sendfriend/product/sendmail',
209  [
210  'id' => $this->getProductId(),
211  'cat_id' => $this->getCategoryId(),
212  ]
213  );
214  }

◆ getUserName()

getUserName ( )

Retrieve username for form field

Returns
string

Definition at line 88 of file Send.php.

89  {
90  $name = $this->getFormData()->getData('sender/name');
91  if (!empty($name)) {
92  return trim($name);
93  }
94 
95  /* @var $session \Magento\Customer\Model\Session */
97 
98  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
99  return $this->_customerViewHelper->getCustomerName(
100  $session->getCustomerDataObject()
101  );
102  }
103 
104  return '';
105  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setFormData()

setFormData (   $data)

Set Form data array

Parameters
array$data
Returns
$this

Definition at line 161 of file Send.php.

162  {
163  if (is_array($data)) {
164  $this->setData('form_data', new \Magento\Framework\DataObject($data));
165  }
166 
167  return $this;
168  }
setData($key, $value=null)
Definition: DataObject.php:72

Field Documentation

◆ $_coreRegistry

$_coreRegistry = null
protected

Definition at line 31 of file Send.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 36 of file Send.php.

◆ $_customerViewHelper

$_customerViewHelper
protected

Definition at line 46 of file Send.php.

◆ $_sendfriendData

$_sendfriendData = null
protected

Definition at line 24 of file Send.php.

◆ $httpContext

$httpContext
protected

Definition at line 41 of file Send.php.

◆ $sendfriend

$sendfriend
protected

Definition at line 51 of file Send.php.


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