Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Wildwoman\LoggedInChecker\Block;
- use Magento\Framework\View\Element\Template as Template;
- use Magento\Framework\App\Http\Context as CustomerContext;
- class Checker extends Template
- {
- /**
- * Current template name
- *
- * @var string
- */
- protected $_template = 'Wildwoman_LoggedInChecker::checker.phtml';
- /**
- * @var CustomerContext
- */
- protected $customerContext;
- /**
- * constructor.
- *
- * @param Context $context
- * @param CustomerContext $customerContext
- * @param array $data
- */
- public function __construct(
- Context $context,
- CustomerContext $customerContext,
- array $data = []
- ) {
- $this->customerContext = $customerContext;
- parent::__construct($context, $data);
- }
- /**
- * Check is Customer Logged In
- *
- * @return int
- */
- public function isCustomerLoggedIn()
- {
- $isLoggedIn = $this->customerContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
- return $isLoggedIn ? 1 : 0 ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement