forked from magepal/magento2-google-tag-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.php
61 lines (52 loc) · 1.25 KB
/
Customer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Copyright © MagePal LLC. All rights reserved.
* See COPYING.txt for license details.
* http://www.magepal.com | [email protected]
*/
namespace MagePal\GoogleTagManager\Model;
use Magento\Customer\Model\Session;
use Magento\Framework\DataObject;
class Customer extends DataObject
{
/**
* @var Session
*/
protected $customerSession;
/**
* Customer constructor.
* @param Session $customerSession
* @param array $data
*/
public function __construct(
Session $customerSession,
array $data = []
) {
$this->customerSession = $customerSession;
parent::__construct($data);
}
/**
* Get Customer array
*
* @return array
*/
public function getCustomer()
{
$isLoggedIn = $this->getCustomerSession()->isLoggedIn();
$data = [
'isLoggedIn' => $isLoggedIn,
];
if ($isLoggedIn) {
$data['id'] = $this->getCustomerSession()->getCustomerId();
$data['groupId'] = $this->getCustomerSession()->getCustomerGroupId();
}
return $data;
}
/**
* @return Session
*/
public function getCustomerSession()
{
return $this->customerSession;
}
}