Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-paypal
Block
Express
InContext
Component.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Paypal\Block\Express\InContext
;
7
8
use
Magento\Paypal\Model\Config
;
9
use Magento\Paypal\Model\ConfigFactory;
10
use
Magento\Framework\View\Element\Template
;
11
use
Magento\Framework\Locale\ResolverInterface
;
12
use
Magento\Framework\View\Element\Template\Context
;
13
20
class
Component
extends
Template
21
{
22
const
IS_BUTTON_CONTEXT_INDEX
=
'is_button_context'
;
23
27
private
$localeResolver;
28
32
private
$config;
33
38
public
function
__construct
(
39
Context
$context,
40
ResolverInterface
$localeResolver,
41
ConfigFactory
$configFactory
,
42
array
$data
= []
43
) {
44
parent::__construct($context,
$data
);
45
$this->localeResolver = $localeResolver;
46
$this->config =
$configFactory
->create();
47
48
$this->config->setMethod(
Config::METHOD_EXPRESS
);
49
}
50
55
protected
function
_toHtml
()
56
{
57
if
(!$this->isInContext()) {
58
return
''
;
59
}
60
61
return
parent::_toHtml();
62
}
63
67
private
function
isInContext()
68
{
69
return
(
bool
)(int) $this->config->getValue(
'in_context'
);
70
}
71
76
public
function
getEnvironment
()
77
{
78
return
(
int
) $this->config->getValue(
'sandbox_flag'
) ?
'sandbox'
:
'production'
;
79
}
80
85
public
function
getLocale
()
86
{
87
return
$this->localeResolver->getLocale();
88
}
89
94
public
function
getMerchantId
()
95
{
96
return
$this->config->getValue(
'merchant_id'
);
97
}
98
103
public
function
isButtonContext
()
104
{
105
return
(
bool
) $this->
getData
(self::IS_BUTTON_CONTEXT_INDEX);
106
}
107
}
Magento\Paypal\Model\Config\METHOD_EXPRESS
const METHOD_EXPRESS
Definition:
Config.php:26
Magento\Framework\View\Element\Template
Definition:
Context.php:6
Magento\Framework\DataObject\getData
getData($key='', $index=null)
Definition:
DataObject.php:119
Magento\Paypal\Block\Express\InContext\Component\IS_BUTTON_CONTEXT_INDEX
const IS_BUTTON_CONTEXT_INDEX
Definition:
Component.php:22
Magento\Paypal\Block\Express\InContext
Definition:
Component.php:6
Magento\Paypal\Block\Express\InContext\Component\_toHtml
_toHtml()
Definition:
Component.php:55
Magento\Framework\View\Element\Template\Context
Definition:
Context.php:23
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento\Paypal\Block\Express\InContext\Component\__construct
__construct(Context $context, ResolverInterface $localeResolver, ConfigFactory $configFactory, array $data=[])
Definition:
Component.php:38
Magento\Paypal\Block\Express\InContext\Component\getLocale
getLocale()
Definition:
Component.php:85
Magento\Framework\Locale\ResolverInterface
Definition:
ResolverInterface.php:14
Magento\Paypal\Block\Express\InContext\Component
Definition:
Component.php:20
Magento\Paypal\Block\Express\InContext\Component\isButtonContext
isButtonContext()
Definition:
Component.php:103
$configFactory
$configFactory
Definition:
config_data.php:43
Magento\Framework\View\Element\Template
Definition:
Template.php:32
Magento\Paypal\Block\Express\InContext\Component\getEnvironment
getEnvironment()
Definition:
Component.php:76
Magento\Paypal\Model\Config
Magento\Paypal\Block\Express\InContext\Component\getMerchantId
getMerchantId()
Definition:
Component.php:94