CustomerData.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Persistent\Model\Plugin;
  7. class CustomerData
  8. {
  9. /**
  10. * Persistent data
  11. *
  12. * @var \Magento\Persistent\Helper\Data
  13. */
  14. protected $persistentData;
  15. /**
  16. * Customer session
  17. *
  18. * @var \Magento\Customer\Model\Session
  19. */
  20. protected $customerSession;
  21. /**
  22. * Persistent session
  23. *
  24. * @var \Magento\Persistent\Helper\Session
  25. */
  26. protected $persistentSession;
  27. /**
  28. * CustomerData constructor.
  29. *
  30. * @param \Magento\Persistent\Helper\Data $persistentData
  31. * @param \Magento\Customer\Model\Session $customerSession
  32. * @param \Magento\Persistent\Helper\Session $persistentSession
  33. */
  34. public function __construct(
  35. \Magento\Persistent\Helper\Data $persistentData,
  36. \Magento\Customer\Model\Session $customerSession,
  37. \Magento\Persistent\Helper\Session $persistentSession
  38. ) {
  39. $this->persistentData = $persistentData;
  40. $this->customerSession = $customerSession;
  41. $this->persistentSession = $persistentSession;
  42. }
  43. /**
  44. * Reset quote reward point amount
  45. *
  46. * @param \Magento\Customer\CustomerData\Customer $subject
  47. * @param \Closure $proceed
  48. *
  49. * @return array
  50. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  51. */
  52. public function aroundGetSectionData(
  53. \Magento\Customer\CustomerData\Customer $subject,
  54. \Closure $proceed
  55. ) {
  56. /** unset customer first name */
  57. if (!$this->customerSession->isLoggedIn()
  58. && $this->persistentData->isEnabled()
  59. && $this->persistentSession->isPersistent()
  60. ) {
  61. return [];
  62. }
  63. return $proceed();
  64. }
  65. }