Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
loginById example
$page
= AccountOrderPage::
createFrom
(
$page
)
;
$page
->
getMetaInformation
(
)
?->
setRobots
(
'noindex,follow'
)
;
$page
->
setOrders
(
StorefrontSearchResult::
createFrom
(
$this
->
getOrders
(
$request
,
$salesChannelContext
)
)
)
;
$page
->
setDeepLinkCode
(
$request
->
get
(
'deepLinkCode'
)
)
;
$firstOrder
=
$page
->
getOrders
(
)
->
getEntities
(
)
->
first
(
)
;
$orderCustomerId
=
$firstOrder
?->
getOrderCustomer
(
)
?->
getCustomer
(
)
?->
getId
(
)
;
if
(
$request
->
get
(
'deepLinkCode'
)
&&
$orderCustomerId
!== null
)
{
$this
->accountService->
loginById
(
$orderCustomerId
,
$salesChannelContext
)
;
}
$this
->eventDispatcher->
dispatch
(
new
AccountOrderPageLoadedEvent
(
$page
,
$salesChannelContext
,
$request
)
)
;
return
$page
;
}
$customer
=
$this
->
getCustomerFromToken
(
$token
,
$salesChannelContext
->
getSalesChannelId
(
)
)
;
static
::
assertSame
(
'foo@bar.com',
$customer
->
getEmail
(
)
)
;
static
::
assertSame
(
$customerId
,
$customer
->
getId
(
)
)
;
}
public
function
testLoginById
(
)
: void
{
$salesChannelContext
=
$this
->
createSalesChannelContext
(
)
;
$customerId
=
$this
->
createCustomerOfSalesChannel
(
$salesChannelContext
->
getSalesChannelId
(
)
, 'foo@bar.com'
)
;
$token
=
$this
->accountService->
loginById
(
$customerId
,
$salesChannelContext
)
;
$customer
=
$this
->
getCustomerFromToken
(
$token
,
$salesChannelContext
->
getSalesChannelId
(
)
)
;
static
::
assertSame
(
'foo@bar.com',
$customer
->
getEmail
(
)
)
;
static
::
assertSame
(
$customerId
,
$customer
->
getId
(
)
)
;
}
public
function
testGetCustomerByLogin
(
)
: void
{
$email
= 'johndoe@example.com';