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

Public Member Functions

 __construct (\Magento\Framework\View\Element\Template\Context $context, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Paypal\Helper\Hss $hssHelper, \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, \Magento\Framework\Module\Dir\Reader $reader, array $data=[])
 
 getFrameActionUrl ()
 
 getSecureToken ()
 
 getSecureTokenId ()
 
 getTransactionUrl ()
 
 isTestMode ()
 
- Public Member Functions inherited from Form
 getMethod ()
 
 setMethod (MethodInterface $method)
 
 getMethodCode ()
 
 getInfoData ($field)
 
- 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

 _construct ()
 
 _getBlock ()
 
 _getOrder ()
 
 _getCheckout ()
 
 _beforeToHtml ()
 
 _toHtml ()
 
 _isAfterPaymentSave ()
 
- 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

 $_shouldRender = false
 
 $_order
 
 $_paymentMethodCode
 
 $_block
 
 $_template = 'Magento_Paypal::hss/js.phtml'
 
 $_orderFactory
 
 $_checkoutSession
 
 $_hssHelper
 
 $readFactory
 
 $reader
 
- 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

HSS iframe block

@api

Since
100.0.2

Definition at line 14 of file Iframe.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Template\Context  $context,
\Magento\Sales\Model\OrderFactory  $orderFactory,
\Magento\Checkout\Model\Session  $checkoutSession,
\Magento\Paypal\Helper\Hss  $hssHelper,
\Magento\Framework\Filesystem\Directory\ReadFactory  $readFactory,
\Magento\Framework\Module\Dir\Reader  $reader,
array  $data = [] 
)
Parameters
\Magento\Framework\View\Element\Template\Context$context
\Magento\Sales\Model\OrderFactory$orderFactory
\Magento\Checkout\Model\Session$checkoutSession
\Magento\Paypal\Helper\Hss$hssHelper
\Magento\Framework\Filesystem\Directory\ReadFactory$readFactory
\Magento\Framework\Module\Dir\Reader$reader
array$data

Definition at line 83 of file Iframe.php.

91  {
92  $this->_hssHelper = $hssHelper;
93  $this->_orderFactory = $orderFactory;
94  $this->_checkoutSession = $checkoutSession;
95  $this->_isScopePrivate = true;
96  $this->readFactory = $readFactory;
97  $this->reader = $reader;
98  parent::__construct($context, $data);
99  }

Member Function Documentation

◆ _beforeToHtml()

_beforeToHtml ( )
protected

Before rendering html, check if is block rendering needed

Returns
\Magento\Framework\View\Element\AbstractBlock

Definition at line 177 of file Iframe.php.

178  {
179  if ($this->_getOrder()->getId() &&
180  $this->_getOrder()->getQuoteId() == $this->_getCheckout()->getLastQuoteId() &&
181  $this->_paymentMethodCode
182  ) {
183  $this->_shouldRender = true;
184  }
185 
186  if ($this->getGotoSection() || $this->getGotoSuccessPage()) {
187  $this->_shouldRender = true;
188  }
189 
190  return parent::_beforeToHtml();
191  }

◆ _construct()

_construct ( )
protected

Internal constructor

Returns
void

Definition at line 106 of file Iframe.php.

107  {
108  parent::_construct();
109  $paymentCode = $this->_getCheckout()->getQuote()->getPayment()->getMethod();
110  if (in_array($paymentCode, $this->_hssHelper->getHssMethods())) {
111  $this->_paymentMethodCode = $paymentCode;
112  $templatePath = str_replace('_', '', $paymentCode);
113  $templateFile = "Magento_Paypal::{$templatePath}/iframe.phtml";
114  $directory = $this->readFactory->create($this->reader->getModuleDir('', 'Magento_Paypal'));
115  $file = $this->resolver->getTemplateFileName($templateFile, ['module' => 'Magento_Paypal']);
116  if ($file && $directory->isExist($directory->getRelativePath($file))) {
117  $this->setTemplate($templateFile);
118  } else {
119  $this->setTemplate('Magento_Paypal::hss/iframe.phtml');
120  }
121  }
122  }

◆ _getBlock()

_getBlock ( )
protected

Get current block instance

Returns
\Magento\Payment\Block\Form
Exceptions

Definition at line 130 of file Iframe.php.

131  {
132  if (!$this->_block) {
133  $this->_block = $this->getLayout()->createBlock(
134  'Magento\\Paypal\\Block\\' . str_replace(
135  ' ',
136  '\\',
137  ucwords(str_replace('_', ' ', $this->_paymentMethodCode))
138  ) . '\\Iframe'
139  );
140  if (!$this->_block instanceof \Magento\Paypal\Block\Iframe) {
141  throw new \Magento\Framework\Exception\LocalizedException(__('Invalid block type'));
142  }
143  }
144 
145  return $this->_block;
146  }
__()
Definition: __.php:13

◆ _getCheckout()

_getCheckout ( )
protected

Get frontend checkout session object

Returns
\Magento\Checkout\Model\Session

Definition at line 167 of file Iframe.php.

168  {
170  }

◆ _getOrder()

_getOrder ( )
protected

Get order object

Returns
\Magento\Sales\Model\Order

Definition at line 153 of file Iframe.php.

154  {
155  if (!$this->_order) {
156  $incrementId = $this->_getCheckout()->getLastRealOrderId();
157  $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
158  }
159  return $this->_order;
160  }

◆ _isAfterPaymentSave()

_isAfterPaymentSave ( )
protected

Check whether block is rendering after save payment

Returns
bool

Definition at line 215 of file Iframe.php.

216  {
217  $quote = $this->_getCheckout()->getQuote();
218  if ($quote->getPayment()->getMethod() == $this->_paymentMethodCode &&
219  $quote->getIsActive() &&
220  $this->getTemplate() &&
221  $this->getRequest()->getActionName() == 'savePayment'
222  ) {
223  return true;
224  }
225 
226  return false;
227  }
$quote

◆ _toHtml()

_toHtml ( )
protected

Render the block if needed

Returns
string

Definition at line 198 of file Iframe.php.

199  {
200  if ($this->_isAfterPaymentSave()) {
201  $this->setTemplate('Magento_Paypal::hss/js.phtml');
202  return parent::_toHtml();
203  }
204  if (!$this->_shouldRender) {
205  return '';
206  }
207  return parent::_toHtml();
208  }

◆ getFrameActionUrl()

getFrameActionUrl ( )

Get iframe action URL

Returns
string

Definition at line 234 of file Iframe.php.

235  {
236  return $this->_getBlock()->getFrameActionUrl();
237  }

◆ getSecureToken()

getSecureToken ( )

Get secure token

Returns
string

Definition at line 244 of file Iframe.php.

245  {
246  return $this->_getBlock()->getSecureToken();
247  }

◆ getSecureTokenId()

getSecureTokenId ( )

Get secure token ID

Returns
string

Definition at line 254 of file Iframe.php.

255  {
256  return $this->_getBlock()->getSecureTokenId();
257  }

◆ getTransactionUrl()

getTransactionUrl ( )

Get payflow transaction URL

Returns
string

Definition at line 264 of file Iframe.php.

265  {
266  return $this->_getBlock()->getTransactionUrl();
267  }

◆ isTestMode()

isTestMode ( )

Check sandbox mode

Returns
bool

Definition at line 274 of file Iframe.php.

275  {
276  return $this->_getBlock()->isTestMode();
277  }

Field Documentation

◆ $_block

$_block
protected

Definition at line 42 of file Iframe.php.

◆ $_checkoutSession

$_checkoutSession
protected

Definition at line 57 of file Iframe.php.

◆ $_hssHelper

$_hssHelper
protected

Definition at line 62 of file Iframe.php.

◆ $_order

$_order
protected

Definition at line 28 of file Iframe.php.

◆ $_orderFactory

$_orderFactory
protected

Definition at line 52 of file Iframe.php.

◆ $_paymentMethodCode

$_paymentMethodCode
protected

Definition at line 35 of file Iframe.php.

◆ $_shouldRender

$_shouldRender = false
protected

Definition at line 21 of file Iframe.php.

◆ $_template

$_template = 'Magento_Paypal::hss/js.phtml'
protected

Definition at line 47 of file Iframe.php.

◆ $reader

$reader
protected

Definition at line 72 of file Iframe.php.

◆ $readFactory

$readFactory
protected

Definition at line 67 of file Iframe.php.


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