Customer.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Account;
  7. use Magento\Customer\Api\CustomerRepositoryInterface;
  8. /**
  9. * @api
  10. * @since 100.0.2
  11. */
  12. class Customer extends \Magento\Framework\View\Element\Template
  13. {
  14. /**
  15. * @var \Magento\Customer\Api\CustomerRepositoryInterface
  16. */
  17. protected $customerRepository;
  18. /**
  19. * @var \Magento\Customer\Helper\View
  20. */
  21. protected $_viewHelper;
  22. /**
  23. * @var \Magento\Framework\App\Http\Context
  24. */
  25. protected $httpContext;
  26. /**
  27. * @param \Magento\Framework\View\Element\Template\Context $context
  28. * @param \Magento\Framework\App\Http\Context $httpContext
  29. * @param array $data
  30. */
  31. public function __construct(
  32. \Magento\Framework\View\Element\Template\Context $context,
  33. \Magento\Framework\App\Http\Context $httpContext,
  34. array $data = []
  35. ) {
  36. parent::__construct($context, $data);
  37. $this->httpContext = $httpContext;
  38. }
  39. /**
  40. * Checking customer login status
  41. *
  42. * @return bool
  43. */
  44. public function customerLoggedIn()
  45. {
  46. return (bool)$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
  47. }
  48. }