本文整理汇总了PHP中Magento\Framework\UrlInterface类的典型用法代码示例。如果您正苦于以下问题:PHP UrlInterface类的具体用法?PHP UrlInterface怎么用?PHP UrlInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UrlInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startTransaction
public function startTransaction(Order $order, UrlInterface $url)
{
$config = new Config($this->_scopeConfig);
$config->configureSDK();
$total = $order->getGrandTotal();
$items = $order->getAllVisibleItems();
$orderId = $order->getIncrementId();
$quoteId = $order->getQuoteId();
$currency = $order->getOrderCurrencyCode();
$returnUrl = $url->getUrl('paynl/checkout/finish/');
$exchangeUrl = $url->getUrl('paynl/checkout/exchange/');
$paymentOptionId = $this->getPaymentOptionId();
$arrBillingAddress = $order->getBillingAddress()->toArray();
$arrShippingAddress = $order->getShippingAddress()->toArray();
$enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
$address = array();
$arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
$address['streetName'] = $arrAddress[0];
$address['houseNumber'] = $arrAddress[1];
$address['zipCode'] = $arrBillingAddress['postcode'];
$address['city'] = $arrBillingAddress['city'];
$address['country'] = $arrBillingAddress['country_id'];
$shippingAddress = array();
$arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
$shippingAddress['streetName'] = $arrAddress2[0];
$shippingAddress['houseNumber'] = $arrAddress2[1];
$shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
$shippingAddress['city'] = $arrShippingAddress['city'];
$shippingAddress['country'] = $arrShippingAddress['country_id'];
$data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
$data['address'] = $address;
$data['shippingAddress'] = $shippingAddress;
$data['enduser'] = $enduser;
$arrProducts = array();
foreach ($items as $item) {
$arrItem = $item->toArray();
if ($arrItem['price_incl_tax'] != null) {
$product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $arrItem['tax_amount']);
}
$arrProducts[] = $product;
}
//shipping
$shippingCost = $order->getShippingAddress()->getShippingInclTax();
$shippingTax = $order->getShippingAddress()->getShippingTaxAmount();
$shippingDescription = $order->getShippingAddress()->getShippingDescription();
$arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
// kortingen
$discount = $order->getSubtotal() - $order->getSubtotalWithDiscount();
if ($discount > 0) {
$arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
}
$data['products'] = $arrProducts;
if ($config->isTestMode()) {
$data['testmode'] = 1;
}
$data['ipaddress'] = $order->getRemoteIp();
$transaction = \Paynl\Transaction::start($data);
return $transaction->getRedirectUrl();
}
示例2: getConfig
/**
* @return array
*/
public function getConfig()
{
// set to active
$config = ['payment' => [self::CODE => ['isActive' => true, 'redirectUrl' => $this->_urlBuilder->getUrl('checkout/onepage/success/', ['_secure' => $this->_getRequest()->isSecure()])]]];
$config['payment']['adyenSepa']['countries'] = $this->_adyenHelper->getSepaCountries();
return $config;
}
示例3: _getConfigUrl
/**
* Get url for config settings where base url option can be changed
*
* @return string
*/
protected function _getConfigUrl()
{
$output = '';
$defaultUnsecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default');
$defaultSecure = $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default');
if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER || $defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER) {
$output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web'));
} else {
/** @var $dataCollection \Magento\Core\Model\Resource\Config\Data\Collection */
$dataCollection = $this->_configValueFactory->create()->getCollection();
$dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER);
/** @var $data \Magento\Framework\App\Config\ValueInterface */
foreach ($dataCollection as $data) {
if ($data->getScope() == 'stores') {
$code = $this->_storeManager->getStore($data->getScopeId())->getCode();
$output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'store' => $code));
break;
} elseif ($data->getScope() == 'websites') {
$code = $this->_storeManager->getWebsite($data->getScopeId())->getCode();
$output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', array('section' => 'web', 'website' => $code));
break;
}
}
}
return $output;
}
示例4: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例5: testGetAction
/**
* @param bool $isSecure
* @param string $actionUrl
* @param int $productId
* @dataProvider getActionDataProvider
*/
public function testGetAction($isSecure, $actionUrl, $productId)
{
$this->urlBuilder->expects($this->any())->method('getUrl')->with('review/product/post', ['_secure' => $isSecure, 'id' => $productId])->willReturn($actionUrl . '/id/' . $productId);
$this->requestMock->expects($this->any())->method('getParam')->with('id', false)->willReturn($productId);
$this->requestMock->expects($this->any())->method('isSecure')->willReturn($isSecure);
$this->assertEquals($actionUrl . '/id/' . $productId, $this->object->getAction());
}
示例6: getUrl
/**
* @param array $queryParams
* @return string
*/
public function getUrl(array $queryParams = [])
{
if (!$this->config->getValue('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
return '';
}
return $this->urlBuilder->getUrl('rss/feed/index', $queryParams);
}
示例7: prepare
/**
* @return void
*/
public function prepare()
{
$config = $this->getData('config');
if (isset($config['options'])) {
$options = [];
foreach ($config['options'] as $option) {
$option['url'] = $this->urlBuilder->getUrl($option['url']);
$options[] = $option;
}
$config['options'] = $options;
}
$store = $this->storeManager->getStore();
$config['validationEnabled'] = $this->config->isAddressValidationEnabled($store);
$hasChoice = $this->config->allowUserToChooseAddress($store);
if ($hasChoice) {
$instructions = $this->config->getAddressValidationInstructionsWithChoice($store);
} else {
$instructions = $this->config->getAddressValidationInstructionsWithOutChoice($store);
}
$config['instructions'] = $instructions;
$config['errorInstructions'] = $this->config->getAddressValidationErrorInstructions($store);
$config['countriesEnabled'] = $this->config->getAddressValidationCountriesEnabled($store);
$config['baseUrl'] = $this->urlBuilder->getUrl(self::VALIDATE_ADDRESS_PATH);
$this->setData('config', $config);
parent::prepare();
}
示例8: prepareDataSource
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (!isset($dataSource['data']['items'])) {
return $dataSource;
}
$hasSubscription = false;
if ($subscription = $this->moduleFactory->create()->load('Swissup_SubscriptionChecker')) {
$hasSubscription = (bool) $subscription->getLocal();
}
foreach ($dataSource['data']['items'] as &$item) {
// add installer links
$module = $this->moduleFactory->create()->load($item['code']);
if ($module->getInstaller()->hasUpgradesDir()) {
$item[$this->getData('name')]['installer'] = ['href' => $this->urlBuilder->getUrl(static::URL_PATH_INSTALL, ['code' => $item['code']]), 'label' => __('Open Installer')];
if ($module->isInstalled() && $module->getInstaller()->getUpgradesToRun()) {
$item[$this->getData('name')]['upgrade'] = ['href' => $this->urlBuilder->getUrl(static::URL_PATH_UPGRADE, ['code' => $item['code']]), 'label' => __('Run Upgrades')];
}
}
// add external links
foreach ($this->getData('links') as $link) {
if (empty($item[$link['key']])) {
continue;
}
if ($link['key'] === 'download_link' && !$hasSubscription) {
continue;
}
$item[$this->getData('name')][$link['key']] = ['href' => $item[$link['key']], 'label' => __($link['label'])];
}
}
return $dataSource;
}
示例9: testGetCurrentSecureUrl
public function testGetCurrentSecureUrl()
{
$request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPathInfo']);
$request->expects($this->once())->method('getPathInfo')->willReturn('/info');
$this->url->expects($this->once())->method('getBaseUrl')->with('link', true)->willReturn('localhost/');
$this->assertEquals('localhost/info', $this->adminPathConfig->getCurrentSecureUrl($request));
}
示例10: testGetUrl
public function testGetUrl()
{
$queryParams = ['queryParamsArray'];
$url = 'sampleUrl';
$this->urlBuilder->expects($this->once())->method('getUrl')->with('sampleservicecontractnew/feed/view', $queryParams)->willReturn($url);
$this->assertEquals($url, $this->target->getUrl($queryParams));
}
示例11: getConfig
/**
* Set configuration for AdyenHPP payemnt method
*
* @return array
*/
public function getConfig()
{
// set to active
$config = ['payment' => [self::CODE => ['isActive' => true, 'redirectUrl' => $this->_urlBuilder->getUrl('adyen/process/redirect', ['_secure' => $this->_getRequest()->isSecure()])]]];
// get customer
if ($this->_customerSession->isLoggedIn()) {
$gender = \Adyen\Payment\Model\Gender::getAdyenGenderFromMagentoGender($this->_customerSession->getCustomerData()->getGender());
// format to calendar date
$dob = $this->_customerSession->getCustomerData()->getDob();
$dob = strtotime($dob);
$dob = date('m/d/Y', $dob);
} else {
$gender = "";
$dob = "";
}
// add to config
$config['payment']['adyenHpp']['gender'] = $gender;
$config['payment']['adyenHpp']['dob'] = $dob;
// gender types
$config['payment']['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes();
$paymentMethodSelectionOnAdyen = $this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
$config['payment']['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;
$config['payment']['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender');
$config['payment']['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob');
$config['payment']['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_telephone');
return $config;
}
示例12: testGetRssData
public function testGetRssData()
{
$rssData = ['title' => 'Pending product review(s)', 'description' => 'Pending product review(s)', 'link' => 'http://rss.magento.com', 'charset' => 'UTF-8', 'entries' => ['title' => 'Product: "Product Name" reviewed by: Product Nick', 'link' => 'http://product.magento.com', 'description' => ['rss_url' => 'http://rss.magento.com', 'name' => 'Product Name', 'summary' => 'Product Title', 'review' => 'Product Detail', 'store' => 'Store Name']]];
$rssUrl = 'http://rss.magento.com';
$productModel = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product', ['getStoreId', 'getId', 'getReviewId', 'getName', 'getDetail', 'getTitle', 'getNickname', 'getProductUrl'], [], '', false);
$storeModel = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->storeManagerInterface->expects($this->once())->method('getStore')->will($this->returnValue($storeModel));
$storeModel->expects($this->once())->method('getName')->will($this->returnValue($rssData['entries']['description']['store']));
$this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue($rssUrl));
$this->urlBuilder->expects($this->once())->method('setScope')->will($this->returnSelf());
$productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
$productModel->expects($this->any())->method('getId')->will($this->returnValue(1));
$productModel->expects($this->once())->method('getReviewId')->will($this->returnValue(1));
$productModel->expects($this->any())->method('getNickName')->will($this->returnValue('Product Nick'));
$productModel->expects($this->any())->method('getName')->will($this->returnValue($rssData['entries']['description']['name']));
$productModel->expects($this->once())->method('getDetail')->will($this->returnValue($rssData['entries']['description']['review']));
$productModel->expects($this->once())->method('getTitle')->will($this->returnValue($rssData['entries']['description']['summary']));
$productModel->expects($this->any())->method('getProductUrl')->will($this->returnValue('http://product.magento.com'));
$this->rss->expects($this->once())->method('getProductCollection')->will($this->returnValue([$productModel]));
$data = $this->block->getRssData();
$this->assertEquals($rssData['title'], $data['title']);
$this->assertEquals($rssData['description'], $data['description']);
$this->assertEquals($rssData['link'], $data['link']);
$this->assertEquals($rssData['charset'], $data['charset']);
$this->assertEquals($rssData['entries']['title'], $data['entries'][0]['title']);
$this->assertEquals($rssData['entries']['link'], $data['entries'][0]['link']);
$this->assertContains($rssData['entries']['description']['rss_url'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['name'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['summary'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['review'], $data['entries'][0]['description']);
$this->assertContains($rssData['entries']['description']['store'], $data['entries'][0]['description']);
}
示例13: getText
/**
* Retrieve message text
*
* @return \Magento\Framework\Phrase
*/
public function getText()
{
$url = $this->urlBuilder->getUrl('indexer/indexer/list');
//@codingStandardsIgnoreStart
return __('One or more <a href="%1">indexers are invalid</a>. Make sure your <a href="%2" target="_blank">Magento cron job</a> is running.', $url, 'http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html#config-cli-cron-bkg');
//@codingStandardsIgnoreEnd
}
示例14: modifyMeta
/**
* {@inheritdoc}
*/
public function modifyMeta(array $meta)
{
if ($name = $this->getGeneralPanelName($meta)) {
$meta[$name]['children']['attribute_set_id']['arguments']['data']['config'] = ['component' => 'Magento_Ui/js/form/element/ui-select', 'disableLabel' => true, 'filterOptions' => true, 'elementTmpl' => 'ui/grid/filters/elements/ui-select', 'formElement' => 'select', 'componentType' => Field::NAME, 'options' => $this->getOptions(), 'visible' => 1, 'required' => 1, 'label' => __('Attribute Set'), 'source' => $name, 'dataScope' => 'attribute_set_id', 'filterUrl' => $this->urlBuilder->getUrl('catalog/product/suggestAttributeSets', ['isAjax' => 'true']), 'sortOrder' => $this->getNextAttributeSortOrder($meta, [ProductAttributeInterface::CODE_STATUS], self::ATTRIBUTE_SET_FIELD_ORDER), 'multiple' => false];
}
return $meta;
}
示例15: getSectionData
/**
* {@inheritdoc}
*/
public function getSectionData()
{
$customerId = $this->currentCustomer->getCustomerId();
if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) {
return ['askToCreate' => true, 'confirmUrl' => $this->escaper->escapeUrl($this->urlBuilder->getUrl($this->startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1])), 'confirmMessage' => $this->escaper->escapeJsQuote(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'))];
}
return [];
}