1
2
3
4
5
6
7
8
9
10
on bir
12
13
14
on beş
on altı
17
18
19
yirmi
yirmi bir
22
23
24
25
26
27
28
29
30
31
32
33
3. 4
35
ad alanı Sağlayıcı\Uzantı\Denetleyici\İstemci;
Magento\Framework\App\Action\Action’ı kullanın;
Magento\Framework\App\Action\Context’i kullanın;
Magento\Client\Model\Session’ı kullanın;
Magento\Framework\App\Http\Context’i AuthContext olarak kullanın;
Sınıf dizini eylemi genişletir.
{
özel $istemci oturumu;
özel $authContext;
genel işlev __construct(Bağlam $bağlam, Oturum $oturum, AuthContext $authContext)
{
$this->customerSession = $session;
$this->authContext = $authContext;
parent::__construction($context);
}
genel işlev çalıştırması()
{
// oturum modelini kullanma
if ($this->customerSession->isLoggedIn())
{
// müşteri giriş kodu
}
geri kalan
{
// istemci oturum açmıyor
}
// HTTP içeriğini kullanma
$isLoggedIn = $this->authContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
if ($isLoggedIn)
{
//kodlamanız
}
}
}