Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
DefaultConfigProvider Class Reference
Inheritance diagram for DefaultConfigProvider:
ConfigProviderInterface

Public Member Functions

 __construct (CheckoutHelper $checkoutHelper, CheckoutSession $checkoutSession, CustomerRepository $customerRepository, CustomerSession $customerSession, CustomerUrlManager $customerUrlManager, HttpContext $httpContext, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, QuoteItemRepository $quoteItemRepository, ShippingMethodManager $shippingMethodManager, ConfigurationPool $configurationPool, QuoteIdMaskFactory $quoteIdMaskFactory, LocaleFormat $localeFormat, \Magento\Customer\Model\Address\Mapper $addressMapper, \Magento\Customer\Model\Address\Config $addressConfig, FormKey $formKey, \Magento\Catalog\Helper\Image $imageHelper, \Magento\Framework\View\ConfigInterface $viewConfig, \Magento\Directory\Model\Country\Postcode\ConfigInterface $postCodesConfig, Cart\ImageProvider $imageProvider, \Magento\Directory\Helper\Data $directoryHelper, CartTotalRepositoryInterface $cartTotalRepository, ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\Config $shippingMethodConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement, UrlInterface $urlBuilder, AddressMetadataInterface $addressMetadata=null, AttributeOptionManagementInterface $attributeOptionManager=null)
 
 getConfig ()
 
 getRegisterUrl ()
 
 getCheckoutUrl ()
 
 pageNotFoundUrl ()
 
 getDefaultSuccessPageUrl ()
 

Protected Member Functions

 getFormattedOptionValue ($item)
 
 getStaticBaseUrl ()
 

Protected Attributes

 $quoteIdMaskFactory
 
 $localeFormat
 
 $addressMapper
 
 $addressConfig
 
 $formKey
 
 $imageHelper
 
 $viewConfig
 
 $postCodesConfig
 
 $directoryHelper
 
 $imageProvider
 
 $cartTotalRepository
 
 $scopeConfig
 
 $shippingMethodConfig
 
 $storeManager
 
 $paymentMethodManagement
 
 $urlBuilder
 

Detailed Description

Default Config Provider

@SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.TooManyFields)

Definition at line 35 of file DefaultConfigProvider.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( CheckoutHelper  $checkoutHelper,
CheckoutSession  $checkoutSession,
CustomerRepository  $customerRepository,
CustomerSession  $customerSession,
CustomerUrlManager  $customerUrlManager,
HttpContext  $httpContext,
\Magento\Quote\Api\CartRepositoryInterface  $quoteRepository,
QuoteItemRepository  $quoteItemRepository,
ShippingMethodManager  $shippingMethodManager,
ConfigurationPool  $configurationPool,
QuoteIdMaskFactory  $quoteIdMaskFactory,
LocaleFormat  $localeFormat,
\Magento\Customer\Model\Address\Mapper  $addressMapper,
\Magento\Customer\Model\Address\Config  $addressConfig,
FormKey  $formKey,
\Magento\Catalog\Helper\Image  $imageHelper,
\Magento\Framework\View\ConfigInterface  $viewConfig,
\Magento\Directory\Model\Country\Postcode\ConfigInterface  $postCodesConfig,
Cart\ImageProvider  $imageProvider,
\Magento\Directory\Helper\Data  $directoryHelper,
CartTotalRepositoryInterface  $cartTotalRepository,
ScopeConfigInterface  $scopeConfig,
\Magento\Shipping\Model\Config  $shippingMethodConfig,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Quote\Api\PaymentMethodManagementInterface  $paymentMethodManagement,
UrlInterface  $urlBuilder,
AddressMetadataInterface  $addressMetadata = null,
AttributeOptionManagementInterface  $attributeOptionManager = null 
)
Parameters
CheckoutHelper$checkoutHelper
Session$checkoutSession
CustomerRepository$customerRepository
CustomerSession$customerSession
CustomerUrlManager$customerUrlManager
HttpContext$httpContext
\Magento\Quote\Api\CartRepositoryInterface$quoteRepository
QuoteItemRepository$quoteItemRepository
ShippingMethodManager$shippingMethodManager
ConfigurationPool$configurationPool
QuoteIdMaskFactory$quoteIdMaskFactory
LocaleFormat$localeFormat
\Magento\Customer\Model\Address\Mapper$addressMapper
\Magento\Customer\Model\Address\Config$addressConfig
FormKey$formKey
\Magento\Catalog\Helper\Image$imageHelper
\Magento\Framework\View\ConfigInterface$viewConfig
\Magento\Directory\Model\Country\Postcode\ConfigInterface$postCodesConfig
Cart\ImageProvider$imageProvider
\Magento\Directory\Helper\Data$directoryHelper
CartTotalRepositoryInterface$cartTotalRepository
ScopeConfigInterface$scopeConfig
\Magento\Shipping\Model\Config$shippingMethodConfig
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Quote\Api\PaymentMethodManagementInterface$paymentMethodManagement
UrlInterface$urlBuilder
AddressMetadataInterface$addressMetadata
AttributeOptionManagementInterface$attributeOptionManager@codeCoverageIgnore @SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 209 of file DefaultConfigProvider.php.

238  {
239  $this->checkoutHelper = $checkoutHelper;
240  $this->checkoutSession = $checkoutSession;
241  $this->customerRepository = $customerRepository;
242  $this->customerSession = $customerSession;
243  $this->customerUrlManager = $customerUrlManager;
244  $this->httpContext = $httpContext;
245  $this->quoteRepository = $quoteRepository;
246  $this->quoteItemRepository = $quoteItemRepository;
247  $this->shippingMethodManager = $shippingMethodManager;
248  $this->configurationPool = $configurationPool;
249  $this->quoteIdMaskFactory = $quoteIdMaskFactory;
250  $this->localeFormat = $localeFormat;
251  $this->addressMapper = $addressMapper;
252  $this->addressConfig = $addressConfig;
253  $this->formKey = $formKey;
254  $this->imageHelper = $imageHelper;
255  $this->viewConfig = $viewConfig;
256  $this->postCodesConfig = $postCodesConfig;
257  $this->imageProvider = $imageProvider;
258  $this->directoryHelper = $directoryHelper;
259  $this->cartTotalRepository = $cartTotalRepository;
260  $this->scopeConfig = $scopeConfig;
261  $this->shippingMethodConfig = $shippingMethodConfig;
262  $this->storeManager = $storeManager;
263  $this->paymentMethodManagement = $paymentMethodManagement;
264  $this->urlBuilder = $urlBuilder;
265  $this->addressMetadata = $addressMetadata ?: ObjectManager::getInstance()->get(AddressMetadataInterface::class);
266  $this->attributeOptionManager = $attributeOptionManager ??
267  ObjectManager::getInstance()->get(AttributeOptionManagementInterface::class);
268  }

Member Function Documentation

◆ getCheckoutUrl()

getCheckoutUrl ( )

Retrieve checkout URL

Returns
string @codeCoverageIgnore

Definition at line 484 of file DefaultConfigProvider.php.

485  {
486  return $this->urlBuilder->getUrl('checkout');
487  }

◆ getConfig()

getConfig ( )

Return configuration array

Returns
array|mixed
Exceptions

Implements ConfigProviderInterface.

Definition at line 276 of file DefaultConfigProvider.php.

277  {
278  $quoteId = $this->checkoutSession->getQuote()->getId();
279  $output['formKey'] = $this->formKey->getFormKey();
280  $output['customerData'] = $this->getCustomerData();
281  $output['quoteData'] = $this->getQuoteData();
282  $output['quoteItemData'] = $this->getQuoteItemData();
283  $output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
284  $output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
285  $output['storeCode'] = $this->getStoreCode();
286  $output['isGuestCheckoutAllowed'] = $this->isGuestCheckoutAllowed();
287  $output['isCustomerLoginRequired'] = $this->isCustomerLoginRequired();
288  $output['registerUrl'] = $this->getRegisterUrl();
289  $output['checkoutUrl'] = $this->getCheckoutUrl();
290  $output['defaultSuccessPageUrl'] = $this->getDefaultSuccessPageUrl();
291  $output['pageNotFoundUrl'] = $this->pageNotFoundUrl();
292  $output['forgotPasswordUrl'] = $this->getForgotPasswordUrl();
293  $output['staticBaseUrl'] = $this->getStaticBaseUrl();
294  $output['priceFormat'] = $this->localeFormat->getPriceFormat(
295  null,
296  $this->checkoutSession->getQuote()->getQuoteCurrencyCode()
297  );
298  $output['basePriceFormat'] = $this->localeFormat->getPriceFormat(
299  null,
300  $this->checkoutSession->getQuote()->getBaseCurrencyCode()
301  );
302  $output['postCodes'] = $this->postCodesConfig->getPostCodes();
303  $output['imageData'] = $this->imageProvider->getImages($quoteId);
304  $output['totalsData'] = $this->getTotalsData();
305  $output['shippingPolicy'] = [
306  'isEnabled' => $this->scopeConfig->isSetFlag(
307  'shipping/shipping_policy/enable_shipping_policy',
309  ),
310  'shippingPolicyContent' => nl2br(
311  $this->scopeConfig->getValue(
312  'shipping/shipping_policy/shipping_policy_content',
314  )
315  )
316  ];
317  $output['activeCarriers'] = $this->getActiveCarriers();
318  $output['originCountryCode'] = $this->getOriginCountryCode();
319  $output['paymentMethods'] = $this->getPaymentMethods();
320  $output['autocomplete'] = $this->isAutocompleteEnabled();
321  $output['displayBillingOnPaymentMethod'] = $this->checkoutHelper->isDisplayBillingOnPaymentMethodAvailable();
322  return $output;
323  }

◆ getDefaultSuccessPageUrl()

getDefaultSuccessPageUrl ( )

Retrieve default success page URL

Returns
string @codeCoverageIgnore

Definition at line 506 of file DefaultConfigProvider.php.

507  {
508  return $this->urlBuilder->getUrl('checkout/onepage/success/');
509  }

◆ getFormattedOptionValue()

getFormattedOptionValue (   $item)
protected

Retrieve formatted item options view

Parameters
\Magento\Quote\Api\Data\CartItemInterface$item
Returns
array

Definition at line 449 of file DefaultConfigProvider.php.

450  {
451  $optionsData = [];
452  $options = $this->configurationPool->getByProductType($item->getProductType())->getOptions($item);
453  foreach ($options as $index => $optionValue) {
454  /* @var $helper \Magento\Catalog\Helper\Product\Configuration */
455  $helper = $this->configurationPool->getByProductType('default');
456  $params = [
457  'max_length' => 55,
458  'cut_replacer' => ' <a href="#" class="dots tooltip toggle" onclick="return false">...</a>'
459  ];
460  $option = $helper->getFormattedOptionValue($optionValue, $params);
462  $optionsData[$index]['label'] = $optionValue['label'];
463  }
464  return $optionsData;
465  }
$helper
Definition: iframe.phtml:13
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
$index
Definition: list.phtml:44

◆ getRegisterUrl()

getRegisterUrl ( )

Retrieve customer registration URL

Returns
string @codeCoverageIgnore

Definition at line 473 of file DefaultConfigProvider.php.

474  {
475  return $this->customerUrlManager->getRegisterUrl();
476  }

◆ getStaticBaseUrl()

getStaticBaseUrl ( )
protected

Return base static url.

Returns
string @codeCoverageIgnore

Definition at line 592 of file DefaultConfigProvider.php.

593  {
594  return $this->checkoutSession->getQuote()->getStore()->getBaseUrl(UrlInterface::URL_TYPE_STATIC);
595  }

◆ pageNotFoundUrl()

pageNotFoundUrl ( )

Retrieve checkout URL

Returns
string @codeCoverageIgnore

Definition at line 495 of file DefaultConfigProvider.php.

496  {
497  return $this->urlBuilder->getUrl('checkout/noroute');
498  }

Field Documentation

◆ $addressConfig

$addressConfig
protected

Definition at line 110 of file DefaultConfigProvider.php.

◆ $addressMapper

$addressMapper
protected

Definition at line 105 of file DefaultConfigProvider.php.

◆ $cartTotalRepository

$cartTotalRepository
protected

Definition at line 145 of file DefaultConfigProvider.php.

◆ $directoryHelper

$directoryHelper
protected

Definition at line 135 of file DefaultConfigProvider.php.

◆ $formKey

$formKey
protected

Definition at line 115 of file DefaultConfigProvider.php.

◆ $imageHelper

$imageHelper
protected

Definition at line 120 of file DefaultConfigProvider.php.

◆ $imageProvider

$imageProvider
protected

Definition at line 140 of file DefaultConfigProvider.php.

◆ $localeFormat

$localeFormat
protected

Definition at line 100 of file DefaultConfigProvider.php.

◆ $paymentMethodManagement

$paymentMethodManagement
protected

Definition at line 165 of file DefaultConfigProvider.php.

◆ $postCodesConfig

$postCodesConfig
protected

Definition at line 130 of file DefaultConfigProvider.php.

◆ $quoteIdMaskFactory

$quoteIdMaskFactory
protected
Parameters
QuoteIdMaskFactory

Definition at line 95 of file DefaultConfigProvider.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 150 of file DefaultConfigProvider.php.

◆ $shippingMethodConfig

$shippingMethodConfig
protected

Definition at line 155 of file DefaultConfigProvider.php.

◆ $storeManager

$storeManager
protected

Definition at line 160 of file DefaultConfigProvider.php.

◆ $urlBuilder

$urlBuilder
protected

Definition at line 170 of file DefaultConfigProvider.php.

◆ $viewConfig

$viewConfig
protected

Definition at line 125 of file DefaultConfigProvider.php.


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