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

Public Member Functions

 __construct (\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory $agreementCollection, \Magento\Paypal\Helper\Data $helper, array $data=[])
 
 getBillingAgreements ()
 
 getItemValue (\Magento\Paypal\Model\Billing\Agreement $item, $key)
 
 getWizardPaymentMethodOptions ()
 
- 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

 _prepareLayout ()
 
 _loadPaymentMethods ()
 
 _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

 $_paymentMethods = []
 
 $_billingAgreements = null
 
 $_customerSession
 
 $_agreementCollection
 
 $_helper
 
- 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

Customer account billing agreements block

@api

Since
100.0.2

Definition at line 14 of file Agreements.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\View\Element\Template\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
\Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory  $agreementCollection,
\Magento\Paypal\Helper\Data  $helper,
array  $data = [] 
)
Parameters
\Magento\Framework\View\Element\Template\Context$context
\Magento\Customer\Model\Session$customerSession
\Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory$agreementCollection
\Magento\Paypal\Helper\Data$helper
array$data

Definition at line 52 of file Agreements.php.

58  {
59  $this->_helper = $helper;
60  $this->_customerSession = $customerSession;
61  $this->_agreementCollection = $agreementCollection;
62  parent::__construct($context, $data);
63  $this->_isScopePrivate = true;
64  }
$helper
Definition: iframe.phtml:13

Member Function Documentation

◆ _loadPaymentMethods()

_loadPaymentMethods ( )
protected

Load available billing agreement methods

Returns
array

Definition at line 143 of file Agreements.php.

144  {
145  if (!$this->_paymentMethods) {
146  foreach ($this->_helper->getBillingAgreementMethods() as $paymentMethod) {
147  $this->_paymentMethods[$paymentMethod->getCode()] = $paymentMethod->getTitle();
148  }
149  }
150  return $this->_paymentMethods;
151  }

◆ _prepareLayout()

_prepareLayout ( )
protected

Set Billing Agreement instance

Returns
$this

Definition at line 71 of file Agreements.php.

72  {
73  parent::_prepareLayout();
74  $pager = $this->getLayout()->createBlock(
75  \Magento\Theme\Block\Html\Pager::class
76  )->setCollection(
77  $this->getBillingAgreements()
78  )->setIsOutputRequired(
79  false
80  );
81  $this->setChild('pager', $pager)->setBackUrl($this->getUrl('customer/account/'));
82  $this->getBillingAgreements()->load();
83  return $this;
84  }

◆ _toHtml()

_toHtml ( )
protected

Set data to block

Returns
string

Definition at line 174 of file Agreements.php.

175  {
176  $this->setCreateUrl($this->getUrl('paypal/billing_agreement/startWizard'));
177  return parent::_toHtml();
178  }

◆ getBillingAgreements()

getBillingAgreements ( )

Retrieve billing agreements collection

Returns
\Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection

Definition at line 91 of file Agreements.php.

92  {
93  if ($this->_billingAgreements === null) {
94  $this->_billingAgreements = $this->_agreementCollection->create()->addFieldToFilter(
95  'customer_id',
96  $this->_customerSession->getCustomerId()
97  )->setOrder(
98  'agreement_id',
99  'desc'
100  );
101  }
103  }

◆ getItemValue()

getItemValue ( \Magento\Paypal\Model\Billing\Agreement  $item,
  $key 
)

Retrieve item value by key

Parameters
\Magento\Framework\DataObject | \Magento\Paypal\Model\Billing\Agreement$item
string$key
Returns
string

Definition at line 112 of file Agreements.php.

113  {
114  switch ($key) {
115  case 'created_at':
116  case 'updated_at':
117  $value = $item->getData($key)
118  ? $this->formatDate($item->getData($key), \IntlDateFormatter::SHORT, true)
119  : __('N/A');
120  break;
121  case 'edit_url':
122  $value = $this->getUrl('paypal/billing_agreement/view', ['agreement' => $item->getAgreementId()]);
123  break;
124  case 'payment_method_label':
125  $label = $item->getAgreementLabel();
126  $value = $label ? $label : __('N/A');
127  break;
128  case 'status':
129  $value = $item->getStatusLabel();
130  break;
131  default:
132  $value = $item->getData($key) ? $item->getData($key) : __('N/A');
133  break;
134  }
135  return $this->escapeHtml($value);
136  }
formatDate( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
__()
Definition: __.php:13
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16

◆ getWizardPaymentMethodOptions()

getWizardPaymentMethodOptions ( )

Retrieve wizard payment options array

Returns
array

Definition at line 158 of file Agreements.php.

159  {
160  $paymentMethodOptions = [];
161  foreach ($this->_helper->getBillingAgreementMethods() as $paymentMethod) {
162  if ($paymentMethod->getConfigData('allow_billing_agreement_wizard') == 1) {
163  $paymentMethodOptions[$paymentMethod->getCode()] = $paymentMethod->getTitle();
164  }
165  }
166  return $paymentMethodOptions;
167  }

Field Documentation

◆ $_agreementCollection

$_agreementCollection
protected

Definition at line 38 of file Agreements.php.

◆ $_billingAgreements

$_billingAgreements = null
protected

Definition at line 28 of file Agreements.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 33 of file Agreements.php.

◆ $_helper

$_helper
protected

Definition at line 43 of file Agreements.php.

◆ $_paymentMethods

$_paymentMethods = []
protected

Definition at line 21 of file Agreements.php.


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