Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Url Class Reference

Public Member Functions

 __construct (Session $customerSession, ScopeConfigInterface $scopeConfig, RequestInterface $request, UrlInterface $urlBuilder, EncoderInterface $urlEncoder, \Magento\Framework\Url\DecoderInterface $urlDecoder=null, \Magento\Framework\Url\HostChecker $hostChecker=null)
 
 getLoginUrl ()
 
 getLoginUrlParams ()
 
 getLoginPostUrl ()
 
 getLogoutUrl ()
 
 getDashboardUrl ()
 
 getAccountUrl ()
 
 getRegisterUrl ()
 
 getRegisterPostUrl ()
 
 getEditUrl ()
 
 getEditPostUrl ()
 
 getForgotPasswordUrl ()
 
 getEmailConfirmationUrl ($email=null)
 

Data Fields

const ROUTE_ACCOUNT_LOGIN = 'customer/account/login'
 
const XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD = 'customer/startup/redirect_dashboard'
 
const REFERER_QUERY_PARAM_NAME = 'referer'
 

Protected Attributes

 $urlBuilder
 
 $request
 
 $scopeConfig
 
 $customerSession
 
 $urlEncoder
 

Detailed Description

Customer url model

Definition at line 17 of file Url.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Session  $customerSession,
ScopeConfigInterface  $scopeConfig,
RequestInterface  $request,
UrlInterface  $urlBuilder,
EncoderInterface  $urlEncoder,
\Magento\Framework\Url\DecoderInterface  $urlDecoder = null,
\Magento\Framework\Url\HostChecker  $hostChecker = null 
)
Parameters
Session$customerSession
ScopeConfigInterface$scopeConfig
RequestInterface$request
UrlInterface$urlBuilder
EncoderInterface$urlEncoder
\Magento\Framework\Url\DecoderInterface | null$urlDecoder
\Magento\Framework\Url\HostChecker | null$hostChecker

Definition at line 78 of file Url.php.

86  {
87  $this->request = $request;
88  $this->urlBuilder = $urlBuilder;
89  $this->scopeConfig = $scopeConfig;
90  $this->customerSession = $customerSession;
91  $this->urlEncoder = $urlEncoder;
92  $this->urlDecoder = $urlDecoder ?: \Magento\Framework\App\ObjectManager::getInstance()
93  ->get(\Magento\Framework\Url\DecoderInterface::class);
94  $this->hostChecker = $hostChecker ?: \Magento\Framework\App\ObjectManager::getInstance()
95  ->get(\Magento\Framework\Url\HostChecker::class);
96  }

Member Function Documentation

◆ getAccountUrl()

getAccountUrl ( )

Retrieve customer account page url

Returns
string

Definition at line 177 of file Url.php.

178  {
179  return $this->urlBuilder->getUrl('customer/account');
180  }

◆ getDashboardUrl()

getDashboardUrl ( )

Retrieve customer dashboard url

Returns
string

Definition at line 167 of file Url.php.

168  {
169  return $this->urlBuilder->getUrl('customer/account');
170  }

◆ getEditPostUrl()

getEditPostUrl ( )

Retrieve customer edit POST URL

Returns
string

Definition at line 217 of file Url.php.

218  {
219  return $this->urlBuilder->getUrl('customer/account/editpost');
220  }

◆ getEditUrl()

getEditUrl ( )

Retrieve customer account edit form url

Returns
string

Definition at line 207 of file Url.php.

208  {
209  return $this->urlBuilder->getUrl('customer/account/edit');
210  }

◆ getEmailConfirmationUrl()

getEmailConfirmationUrl (   $email = null)

Retrieve confirmation URL for Email

Parameters
string$email
Returns
string

Definition at line 238 of file Url.php.

239  {
240  return $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]);
241  }
$email
Definition: details.phtml:13

◆ getForgotPasswordUrl()

getForgotPasswordUrl ( )

Retrieve url of forgot password page

Returns
string

Definition at line 227 of file Url.php.

228  {
229  return $this->urlBuilder->getUrl('customer/account/forgotpassword');
230  }

◆ getLoginPostUrl()

getLoginPostUrl ( )

Retrieve customer login POST URL

Returns
string

Definition at line 140 of file Url.php.

141  {
142  $params = [];
143  $referer = $this->getRequestReferrer();
144  if ($referer) {
145  $params = [
146  self::REFERER_QUERY_PARAM_NAME => $referer,
147  ];
148  }
149  return $this->urlBuilder->getUrl('customer/account/loginPost', $params);
150  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getLoginUrl()

getLoginUrl ( )

Retrieve customer login url

Returns
string

Definition at line 103 of file Url.php.

104  {
105  return $this->urlBuilder->getUrl(self::ROUTE_ACCOUNT_LOGIN, $this->getLoginUrlParams());
106  }

◆ getLoginUrlParams()

getLoginUrlParams ( )

Retrieve parameters of customer login url

Returns
array

Definition at line 113 of file Url.php.

114  {
115  $params = [];
116  $referer = $this->getRequestReferrer();
117  if (!$referer
118  && !$this->scopeConfig->isSetFlag(
119  self::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
120  ScopeInterface::SCOPE_STORE
121  )
122  && !$this->customerSession->getNoReferer()
123  ) {
124  $referer = $this->urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
125  $referer = $this->urlEncoder->encode($referer);
126  }
127 
128  if ($referer) {
129  $params = [self::REFERER_QUERY_PARAM_NAME => $referer];
130  }
131 
132  return $params;
133  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getLogoutUrl()

getLogoutUrl ( )

Retrieve customer logout url

Returns
string

Definition at line 157 of file Url.php.

158  {
159  return $this->urlBuilder->getUrl('customer/account/logout');
160  }

◆ getRegisterPostUrl()

getRegisterPostUrl ( )

Retrieve customer register form post url

Returns
string

Definition at line 197 of file Url.php.

198  {
199  return $this->urlBuilder->getUrl('customer/account/createpost');
200  }

◆ getRegisterUrl()

getRegisterUrl ( )

Retrieve customer register form url

Returns
string

Definition at line 187 of file Url.php.

188  {
189  return $this->urlBuilder->getUrl('customer/account/create');
190  }

Field Documentation

◆ $customerSession

$customerSession
protected

Definition at line 52 of file Url.php.

◆ $request

$request
protected

Definition at line 42 of file Url.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 47 of file Url.php.

◆ $urlBuilder

$urlBuilder
protected

Definition at line 37 of file Url.php.

◆ $urlEncoder

$urlEncoder
protected

Definition at line 57 of file Url.php.

◆ REFERER_QUERY_PARAM_NAME

const REFERER_QUERY_PARAM_NAME = 'referer'

Query param name for last url visited

Definition at line 32 of file Url.php.

◆ ROUTE_ACCOUNT_LOGIN

const ROUTE_ACCOUNT_LOGIN = 'customer/account/login'

Route for customer account login page

Definition at line 22 of file Url.php.

◆ XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD

const XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD = 'customer/startup/redirect_dashboard'

Config name for Redirect Customer to Account Dashboard after Logging in setting

Definition at line 27 of file Url.php.


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