RegistrationFactory.php
2.34 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace FootyRoom\Services\Registration;
use FootyRoom\Config;
use FootyRoom\Services\Registration\FacebookRegistration;
use FootyRoom\Services\Registration\Registration;
use FootyRoom\Repositories\IUserRepository;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Events\Dispatcher;
class RegistrationFactory
{
/**
* @var \FootyRoom\Repositories\UserRepository
*/
protected $userRepo;
/**
* @var \FootyRoom\Services\Registration\ActivationKeyMailer
*/
protected $activationKeyMailer;
/**
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $auth;
/**
* @var \FootyRoom\Config
*/
protected $config;
/**
* @var \Illuminate\Contracts\Events\Dispatcher;
*/
protected $events;
/**
* Constructor.
*
* @param \FootyRoom\Repositories\IUserRepository $userRepo
* @param \FootyRoom\Services\Registration\ActivationKeyMailer $activationKeyMailer
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \FootyRoom\Config $config
*/
public function __construct(
IUserRepository $userRepo,
ActivationKeyMailer $activationKeyMailer,
Guard $auth,
Config $config,
Dispatcher $events
) {
$this->userRepo = $userRepo;
$this->activationKeyMailer = $activationKeyMailer;
$this->auth = $auth;
$this->config = $config;
$this->events = $events;
}
/**
* Creates specific registration depending on submitted user data.
*
* @param array $userData User data that will be passed on to registration.
*
* @return \FootyRoom\Services\Registration\Registration|\FootyRoom\Services\Registration\FacebookRegistration
*/
public function make($userData)
{
if (isset($userData['fbtoken'])) {
return new FacebookRegistration(
$userData,
$this->userRepo,
$this->activationKeyMailer,
$this->auth,
$this->config,
$this->events
);
} else {
return new Registration(
$userData,
$this->userRepo,
$this->activationKeyMailer,
$this->events
);
}
}
}