1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Foxy\SingleSignOn\Factory; |
4
|
|
|
|
5
|
|
|
use Dynamic\Foxy\Orders\Factory\FoxyFactory; |
|
|
|
|
6
|
|
|
use Dynamic\Foxy\Parser\Foxy\Transaction; |
|
|
|
|
7
|
|
|
use SilverStripe\Core\Config\Configurable; |
8
|
|
|
use SilverStripe\Core\Extensible; |
9
|
|
|
use SilverStripe\Core\Injector\Injectable; |
10
|
|
|
use SilverStripe\Security\Member; |
11
|
|
|
use SilverStripe\Security\Security; |
12
|
|
|
use SilverStripe\View\ArrayData; |
13
|
|
|
|
14
|
|
|
class MemberFactory |
15
|
|
|
{ |
16
|
|
|
use Configurable; |
17
|
|
|
use Extensible; |
18
|
|
|
use Injectable; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Transaction |
22
|
|
|
*/ |
23
|
|
|
private $transaction; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var |
27
|
|
|
*/ |
28
|
|
|
private $member; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* OrderDetailFactory constructor. |
32
|
|
|
* @param Transaction|null $transaction |
33
|
|
|
*/ |
34
|
|
|
public function __construct(Transaction $transaction = null) |
35
|
|
|
{ |
36
|
|
|
if ($transaction instanceof Transaction && $transaction !== null) { |
37
|
|
|
$this->setTransaction($transaction); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param Transaction $transaction |
43
|
|
|
* @return $this |
44
|
|
|
*/ |
45
|
|
|
public function setTransaction(Transaction $transaction) |
46
|
|
|
{ |
47
|
|
|
$this->transaction = $transaction; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return Transaction |
54
|
|
|
*/ |
55
|
|
|
protected function getTransaction() |
56
|
|
|
{ |
57
|
|
|
return $this->transaction; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Member |
62
|
|
|
*/ |
63
|
|
|
public function getMember() |
64
|
|
|
{ |
65
|
|
|
if (!$this->member instanceof Member) { |
66
|
|
|
$this->setMember(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $this->member; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
protected function setMember() |
73
|
|
|
{ |
74
|
|
|
/** @var ArrayData $transaction */ |
75
|
|
|
$transaction = $this->getTransaction()->getParsedTransactionData()->getField('transaction'); |
76
|
|
|
|
77
|
|
|
// if not a guest transaction in Foxy |
78
|
|
|
if ($transaction->getField('customer_email') |
79
|
|
|
&& $transaction->getField('is_anonymous') == 0) { |
80
|
|
|
|
81
|
|
|
/** @var $encryption - disable password encryption to prevent double encryption */ |
82
|
|
|
$encryption = Config::inst()->get(Security::class, 'password_encryption_algorithm'); |
|
|
|
|
83
|
|
|
Config::modify()->set(Security::class, 'password_encryption_algorithm', 'none'); |
84
|
|
|
|
85
|
|
|
if (!$customer = Member::get()->filter('Email', $transaction->getField('customer_email'))->first()) { |
86
|
|
|
$customer = Member::create(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
foreach ($this->config()->get('member_mapping') as $foxy => $ssFoxy) { |
90
|
|
|
if ($transaction->hasField($foxy)) { |
91
|
|
|
$order->{$ssFoxy} = $transaction->getField($foxy); |
|
|
|
|
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** manuall set encryption type to sha1 */ |
96
|
|
|
$customer->PasswordEncryption = 'sha1'; |
97
|
|
|
|
98
|
|
|
/** flag to prevent push to Foxy on write */ |
99
|
|
|
$customer->FromDataFeed = true; |
100
|
|
|
|
101
|
|
|
$customer->write(); |
102
|
|
|
|
103
|
|
|
/** re-enable password encryption */ |
104
|
|
|
Config::modify()->set(Security::class, 'password_encryption_algorithm', $encryption); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths