本文整理汇总了PHP中Magento\Framework\UrlInterface::getUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlInterface::getUrl方法的具体用法?PHP UrlInterface::getUrl怎么用?PHP UrlInterface::getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\UrlInterface
的用法示例。
在下文中一共展示了UrlInterface::getUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例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: 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
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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();
}
示例9: 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();
}
示例10: 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 [];
}
示例11: _addBreadcrumbs
/**
* Prepare breadcrumbs
*
* @param \Magento\Cms\Model\Post $post
* @throws \Magento\Framework\Exception\LocalizedException
* @return void
*/
protected function _addBreadcrumbs(\OsmanSorkar\Blog\Model\Post $post)
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl()]);
$breadcrumbsBlock->addCrumb('blog', ['label' => __("blog"), 'title' => __("Go to Blog"), 'link' => __($this->urlBuilder->getUrl("blog/"))]);
$breadcrumbsBlock->addCrumb('blog_Post', ['label' => $post->getTitle(), 'title' => $post->getTitle()]);
}
}
示例12: processRedirect
/**
* @param \Magento\Framework\App\RequestInterface $request
* @param UrlRewrite $rewrite
* @return \Magento\Framework\App\ActionInterface|null
*/
protected function processRedirect($request, $rewrite)
{
$target = $rewrite->getTargetPath();
if ($rewrite->getEntityType() !== Rewrite::ENTITY_TYPE_CUSTOM || ($prefix = substr($target, 0, 6)) !== 'http:/' && $prefix !== 'https:') {
$target = $this->url->getUrl('', ['_direct' => $target]);
}
return $this->redirect($request, $target, $rewrite->getRedirectType());
}
示例13: modifyMeta
/**
* {@inheritdoc}
*/
public function modifyMeta(array $meta)
{
if (!$this->locator->getProduct()->getId()) {
return $meta;
}
$meta[static::GROUP_REVIEW] = ['children' => ['review_listing' => ['arguments' => ['data' => ['config' => ['autoRender' => true, 'componentType' => 'insertListing', 'dataScope' => 'review_listing', 'externalProvider' => 'review_listing.review_listing_data_source', 'selectionsProvider' => 'review_listing.review_listing.product_columns.ids', 'ns' => 'review_listing', 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), 'realTimeLink' => false, 'behaviourType' => 'simple', 'externalFilterMode' => true, 'imports' => ['productId' => '${ $.provider }:data.product.current_product_id'], 'exports' => ['productId' => '${ $.externalProvider }:params.current_product_id']]]]]], 'arguments' => ['data' => ['config' => ['label' => __('Product Reviews'), 'collapsible' => true, 'opened' => false, 'componentType' => Form\Fieldset::NAME, 'sortOrder' => $this->getNextGroupSortOrder($meta, static::GROUP_CONTENT, static::SORT_ORDER)]]]];
return $meta;
}
示例14: beforeGetTargetStorePostData
/**
* Set redirect url for store view based on request path info
*
* @param \Magento\Store\Block\Switcher $switcher
* @param \Magento\Store\Model\Store $store
* @param array $data
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = [])
{
$urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]);
if ($urlRewrite) {
$data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath())));
}
return [$store, $data];
}
示例15: aroundDispatch
/**
* Dispatch request
*
* @param \Magento\Framework\App\Action\Action $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function aroundDispatch(\Magento\Framework\App\Action\Action $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->_appState->isInstalled()) {
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->_response->setRedirect($this->_url->getUrl('install'));
return $this->_response;
}
return $proceed($request);
}