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

Public Member Functions

 __construct (Session $customerSession, HttpContext $httpContext)
 
 beforeDispatch (AbstractAction $subject, RequestInterface $request)
 

Protected Attributes

 $customerSession
 
 $httpContext
 

Detailed Description

Class ContextPlugin

Definition at line 19 of file ContextPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Session  $customerSession,
HttpContext  $httpContext 
)
Parameters
Session$customerSession
HttpContext$httpContext

Definition at line 35 of file ContextPlugin.php.

36  {
37  $this->customerSession = $customerSession;
38  $this->httpContext = $httpContext;
39  }

Member Function Documentation

◆ beforeDispatch()

beforeDispatch ( AbstractAction  $subject,
RequestInterface  $request 
)

Set customer group and customer session id to HTTP context

Parameters
AbstractAction$subject
RequestInterface$request
Returns
void @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 49 of file ContextPlugin.php.

50  {
51  $this->httpContext->setValue(
53  $this->customerSession->getCustomerGroupId(),
55  );
56  $this->httpContext->setValue(
58  $this->customerSession->isLoggedIn(),
59  false
60  );
61  }
return false
Definition: gallery.phtml:36

Field Documentation

◆ $customerSession

$customerSession
protected

Definition at line 24 of file ContextPlugin.php.

◆ $httpContext

$httpContext
protected

Definition at line 29 of file ContextPlugin.php.


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