Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
16  const KEY_ACTIVE = 'active';
17 
18  const KEY_TITLE = 'title';
19 
20  const KEY_DISPLAY_ON_SHOPPING_CART = 'display_on_shopping_cart';
21 
22  const KEY_ALLOW_TO_EDIT_SHIPPING_ADDRESS = 'allow_shipping_address_override';
23 
24  const KEY_MERCHANT_NAME_OVERRIDE = 'merchant_name_override';
25 
26  const KEY_REQUIRE_BILLING_ADDRESS = 'require_billing_address';
27 
31  private $ccConfig;
32 
36  private $icon = [];
37 
46  public function __construct(
47  ScopeConfigInterface $scopeConfig,
48  CcConfig $ccConfig,
49  $methodCode = null,
50  $pathPattern = self::DEFAULT_PATH_PATTERN
51  ) {
52  parent::__construct($scopeConfig, $methodCode, $pathPattern);
53  $this->ccConfig = $ccConfig;
54  }
55 
61  public function isActive()
62  {
63  return (bool) $this->getValue(self::KEY_ACTIVE);
64  }
65 
69  public function isDisplayShoppingCart()
70  {
71  return (bool) $this->getValue(self::KEY_DISPLAY_ON_SHOPPING_CART);
72  }
73 
79  public function isAllowToEditShippingAddress()
80  {
81  return (bool) $this->getValue(self::KEY_ALLOW_TO_EDIT_SHIPPING_ADDRESS);
82  }
83 
89  public function getMerchantName()
90  {
91  return $this->getValue(self::KEY_MERCHANT_NAME_OVERRIDE);
92  }
93 
99  public function isRequiredBillingAddress()
100  {
101  return $this->getValue(self::KEY_REQUIRE_BILLING_ADDRESS);
102  }
103 
109  public function getTitle()
110  {
111  return $this->getValue(self::KEY_TITLE);
112  }
113 
118  public function isSkipOrderReview()
119  {
120  return (bool) $this->getValue('skip_order_review');
121  }
122 
127  public function getPayPalIcon()
128  {
129  if (empty($this->icon)) {
130  $asset = $this->ccConfig->createAsset('Magento_Braintree::images/paypal.png');
131  list($width, $height) = getimagesize($asset->getSourceFile());
132  $this->icon = [
133  'url' => $asset->getUrl(),
134  'width' => $width,
135  'height' => $height
136  ];
137  }
138 
139  return $this->icon;
140  }
141 }
$pathPattern
__construct(ScopeConfigInterface $scopeConfig, CcConfig $ccConfig, $methodCode=null, $pathPattern=self::DEFAULT_PATH_PATTERN)
Definition: Config.php:46
getValue($field, $storeId=null)
Definition: Config.php:83