Test Failed
Pull Request — master (#140)
by Litera
10:13
created

RegistrationPresenter::actionCreate()   A

Complexity

Conditions 2
Paths 8

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
c 0
b 0
f 0
cc 2
eloc 15
nc 8
nop 0
rs 9.0856
1
<?php
2
3
namespace App\Presenters;
4
5
use DateTime;
6
use Exception;
7
use App\Entities\VisitorEntity;
8
use App\Models\MeetingModel;
9
use App\Models\VisitorModel;
10
use App\Models\MealModel;
11
use App\Services\SkautIS\UserService;
12
use App\Services\Emailer;
13
use App\Services\VisitorService;
14
use App\Repositories\ProgramRepository;
15
use Tracy\Debugger;
16
use App\Components\Forms\RegistrationForm;
17
use App\Components\Forms\Factories\IRegistrationFormFactory;
18
use App\Services\SkautIS\EventService;
19
use Skautis\Wsdl\WsdlException;
20
use App\Models\SettingsModel;
21
22
/**
23
 * Registration controller
24
 *
25
 * This file handles the registration of visitors
26
 *
27
 * @author Tomas Litera
28
 * @copyright 2013-06-12 <[email protected]>
29
 * @package srazvs
30
 */
31
class RegistrationPresenter extends VisitorPresenter
32
{
33
34
	/**
35
	 * @var VisitorModel
36
	 */
37
	private $visitorModel;
38
39
	/**
40
	 * @var UserService
41
	 */
42
	private $userService;
43
44
	/**
45
	 * @var ProgramRepository
46
	 */
47
	private $programRepository;
48
49
	/**
50
	 * @var SettingsModel
51
	 */
52
	protected $settingsModel;
53
54
	/**
55
	 * @var boolean
56
	 */
57
	private $disabled = false;
58
59
	/**
60
	 * @var IRegistrationFormFactory
61
	 */
62
	private $registrationFormFactory;
63
64
	/**
65
	 * @var EventService
66
	 */
67
	protected $skautisEventService;
68
69
	/**
70
	 * @param MeetingModel       $meetingModel
71
	 * @param UserService        $userService
72
	 * @param VisitorModel       $visitorModel
73
	 * @param MealModel          $mealModel
74
	 * @param ProgramRepository  $programRepository
75
	 * @param VisitorService     $visitorService
76
	 * @param SettingsModel      $settingsModel
77
	 */
78
	public function __construct(
79
		MeetingModel $meetingModel,
80
		UserService $userService,
81
		VisitorModel $visitorModel,
82
		MealModel $mealModel,
83
		Emailer $emailer,
84
		VisitorService $visitorService,
85
		ProgramRepository $programRepository,
86
		EventService $skautisEvent,
87
		SettingsModel $settingsModel
88
	) {
89
		$this->setMeetingModel($meetingModel);
90
		$this->setUserService($userService);
91
		$this->setVisitorModel($visitorModel);
92
		$this->setMealModel($mealModel);
93
		$this->setEmailer($emailer);
94
		$this->setVisitorService($visitorService);
95
		$this->setProgramRepository($programRepository);
96
		$this->setEventService($skautisEvent);
97
		$this->setSettingsModel($settingsModel);
98
	}
99
100
	/**
101
	 * @return IRegistrationFormFactory
102
	 */
103
	public function getRegistrationFormFactory(): IRegistrationFormFactory
104
	{
105
		return $this->registrationFormFactory;
106
	}
107
108
	/**
109
	 * Injector
110
	 *
111
	 * @param  IRegistrationFormFactory $factory
112
	 */
113
114
	protected $error = FALSE;
115
116
	protected $hash = NULL;
117
	private $item;
118
	private $mealData;
119
	private $user;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
120
	private $event;
121
122
	public function injectRegistrationFormFactory(IRegistrationFormFactory $factory)
123
	{
124
		$this->registrationFormFactory = $factory;
125
	}
126
127
	/**
128
	 * @return void
129
	 */
130
	public function startup()
131
	{
132
		parent::startup();
133
134
		$this->getMeetingModel()->setMeetingId($this->getMeetingId());
135
136
		if($this->getDebugMode() || $this->getSettingsModel()->findDebugRegime()) {
137
			$this->getMeetingModel()->setRegistrationHandlers(1);
138
			$this->setMeetingId(1);
139
		} else {
140
			$this->getMeetingModel()->setRegistrationHandlers($this->getMeetingId());
141
		}
142
143
		//$this->user = $this->container->getService('userService');
144
		//$this->event = $this->container->getService('eventService');
145
146
		$template = $this->getTemplate();
147
148
		$template->page_title = "Registrace srazu VS";
0 ignored issues
show
Bug introduced by
Accessing page_title on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
149
		$template->meeting_heading = $this->getMeetingModel()->getRegHeading();
0 ignored issues
show
Bug introduced by
Accessing meeting_heading on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
150
		$template->isRegistrationOpen = $this->getMeetingModel()->isRegOpen($this->getDebugMode());
0 ignored issues
show
Bug introduced by
Accessing isRegistrationOpen on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
151
	}
152
153
	/**
154
	 * Process data from form
155
	 *
156
	 * @return void
157
	 */
158
	public function actionCreate()
159
	{
160
		try {
161
			$postData = $this->getHttpRequest()->getPost();
162
			$postData['meeting'] = $this->getMeetingId();
163
164
			$guid = $this->getVisitorService()->create($postData);
165
			$result = $this->sendRegistrationSummary($postData, $guid);
166
167
			$this->logInfo('Creation of registration(%s) successfull, result: %s', [
168
				$guid,
169
				json_encode($result),
170
			]);
171
			$this->flashSuccess("Registrace({$guid}) byla úspěšně založena.");
172
173
			$this->redirect('Registration:check', $guid);
174
		} catch(Exception $e) {
175
			$this->logError('Creation of registration failed, result: %s', [
176
				$e->getMessage(),
177
			]);
178
			$this->flashError('Creation of registration failed, result: ' . $e->getMessage());
179
		}
180
	}
181
182
	/**
183
	 * @param  string  $guid
184
	 * @return void
185
	 */
186
	public function actionUpdate($guid)
187
	{
188
		try {
189
			$postData = $this->getHttpRequest()->getPost();
190
191
			$result = $this->getVisitorService()->update($guid, $postData);
192
			$result = $this->sendRegistrationSummary($postData, $guid);
193
194
			$this->logInfo('Modification of registration(%s) successfull, result: %s', [
195
				$guid,
196
				json_encode($result),
197
			]);
198
			$this->flashSuccess("Registrace({$guid}) byla úspěšně upravena.");
199
		} catch(Exception $e) {
200
			$this->logError('Modification of registration(%s) failed, result: %s', [
201
				$guid,
202
				$e->getMessage(),
203
			]);
204
			$this->flashError("Modification of registration({$guid}) failed, result: " . $e->getMessage());
205
		}
206
207
		$this->redirect('Registration:check', $guid);
208
	}
209
210
	/**
211
	 * Renders default template
212
	 */
213
	public function renderDefault()
214
	{
215
		$template = $this->getTemplate();
216
		$disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
217
		$template->disabled = $disabled;
0 ignored issues
show
Bug introduced by
Accessing disabled on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
218
		$template->loggedIn = $this->getUserService()->isLoggedIn();
0 ignored issues
show
Bug introduced by
Accessing loggedIn on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
219
220
		if($this->getUserService()->isLoggedIn()) {
221
			$this['registrationForm']->setDefaults(($this->useLoggedVisitor())->toArray());
222
		}
223
	}
224
225
	/**
226
	 * Renders new template
227
	 */
228
	public function renderNew()
229
	{
230
		$template = $this->getTemplate();
231
		$disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
232
		$template->disabled = $disabled;
0 ignored issues
show
Bug introduced by
Accessing disabled on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
233
		$template->loggedIn = false;
0 ignored issues
show
Bug introduced by
Accessing loggedIn on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
234
	}
235
236
	/**
237
	 * @param  string  $guid
238
	 * @return void
239
	 */
240
	public function renderCheck($guid)
241
	{
242
		$visitor = $this->getVisitorModel()->findByGuid($guid);
243
244
		$this->getMeetingModel()->setRegistrationHandlers($visitor->meeting);
245
246
		$template = $this->getTemplate();
247
		$template->guid = $guid;
0 ignored issues
show
Bug introduced by
Accessing guid on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
248
		$template->visitor = $visitor;
0 ignored issues
show
Bug introduced by
Accessing visitor on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
249
		$template->meetingId = $visitor->meeting;
0 ignored issues
show
Bug introduced by
Accessing meetingId on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
250
		$template->meals = $this->getMealModel()->findByVisitorId($visitor->id);
0 ignored issues
show
Bug introduced by
Accessing meals on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
251
		$template->province = $this->getMeetingModel()->getProvinceNameById($visitor->province);
0 ignored issues
show
Bug introduced by
Accessing province on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
252
		$template->programs = $this->getProgramRepository()->findByVisitorId($visitor->id);
0 ignored issues
show
Bug introduced by
Accessing programs on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
253
	}
254
255
	/**
256
	 * @param  string $guid
257
	 * @return void
258
	 */
259
	public function renderEdit($guid)
260
	{
261
		$visitor = $this->getVisitorService()->findByGuid($guid);
262
		$meetingId = $visitor['meeting'];
263
264
		$this->getMeetingModel()->setRegistrationHandlers($meetingId);
265
266
		$template = $this->getTemplate();
267
		$template->guid = $guid;
0 ignored issues
show
Bug introduced by
Accessing guid on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
268
		$template->meetingId = $meetingId;
0 ignored issues
show
Bug introduced by
Accessing meetingId on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
269
		$template->loggedIn = $this->getUserService()->isLoggedIn();
0 ignored issues
show
Bug introduced by
Accessing loggedIn on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
270
		$template->disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
0 ignored issues
show
Bug introduced by
Accessing disabled on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
271
272
		$this['registrationForm']->setDefaults($visitor);
273
	}
274
275
	/**
276
	 * @return RegistrationFormControl
277
	 */
278
	protected function createComponentRegistrationForm(): RegistrationForm
279
	{
280
		$control = $this->registrationFormFactory->create();
281
		$control->setMeetingId($this->getMeetingId());
282
		$control->onRegistrationSave[] = function(RegistrationForm $control, $newVisitor) {
283
			try {
284
				$guid = $this->getParameter('guid');
285
286
				if($guid) {
287
					$guid = $this->getVisitorService()->update($guid, (array) $newVisitor);
288
				} else {
289
					$guid = $this->getVisitorService()->create((array) $newVisitor);
290
				}
291
/*
292
				if($this->getUserService()->isLoggedIn() && $this->getMeetingModel()->findCourseId()) {
293
					$this->getEventService()->insertEnroll(
294
						$this->getUserService()->getSkautis()->getUser()->getLoginId(),
295
						$this->getMeetingModel()->findCourseId(),
296
						// TODO: get real phone number
297
						'123456789'
298
					);
299
				}
300
*/
301
				$result = $this->sendRegistrationSummary((array) $newVisitor, $guid);
302
303
				$this->logInfo('Storage of visitor(%s) successfull, result: %s', [
304
					$guid,
305
					json_encode($result),
306
				]);
307
				$this->flashSuccess("Účastník({$guid}) byl úspěšně uložen.");
308
			} catch(WsdlException $e) {
309
				$this->logWarning('Storage of visitor(%s) failed, result: %s', [
310
					$guid,
311
					$e->getMessage(),
312
				]);
313
				$this->flashError("Uložení účastníka ({$guid}) selhalo. Účastník je již zaregistrován.");
314
			} catch(Exception $e) {
315
				$this->logError('Storage of visitor(%s) failed, result: %s', [
316
					$guid,
317
					$e->getMessage(),
318
				]);
319
				$this->flashError('Uložení účastníka selhalo, chyba: ' . $e->getMessage());
320
			}
321
322
			$this->redirect('Registration:check', $guid);
323
		};
324
325
		return $control;
326
	}
327
328
	/**
329
	 * @return VisitorEntity
330
	 */
331
	protected function useLoggedVisitor(): VisitorEntity
332
	{
333
		$userDetail = $this->getUserService()->getUserDetail();
334
		$skautisUser = $this->getUserService()->getPersonalDetail($userDetail->ID_Person);
335
		$membership = $this->getUserService()->getPersonUnitDetail($userDetail->ID_Person);
336
337
		if(!preg_match('/^[1-9]{1}[0-9a-zA-Z]{2}\.[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}$/', $membership->RegistrationNumber)) {
338
			$skautisUserUnit = $this->getUserService()->getParentUnitDetail($membership->ID_Unit)[0];
339
		} else {
340
			$skautisUserUnit = $this->getUserService()->getUnitDetail($membership->ID_Unit);
341
		}
342
343
		$visitor = new VisitorEntity;
344
		$visitor->name = $skautisUser->FirstName;
345
		$visitor->surname = $skautisUser->LastName;
346
		$visitor->nick = $skautisUser->NickName;
347
		$visitor->email = $skautisUser->Email;
348
		$visitor->street = $skautisUser->Street;
349
		$visitor->city = $skautisUser->City;
350
		$visitor->postal_code = preg_replace('/\s+/', '', $skautisUser->Postcode);
351
		$visitor->birthday = (new DateTime($skautisUser->Birthday))->format('d. m. Y');
352
		$visitor->group_name = $skautisUserUnit->DisplayName;
353
		$visitor->group_num = $skautisUserUnit->RegistrationNumber;
354
		if(isset($membership->Unit)) {
355
			$visitor->troop_name = $membership->Unit;
356
		}
357
358
		return $visitor;
359
	}
360
361
	/**
362
	 * @return MealModel
363
	 */
364
	protected function getMealModel()
365
	{
366
		return $this->mealModel;
367
	}
368
369
	/**
370
	 * @param  MealModel $model
371
	 * @return $this
372
	 */
373
	protected function setMealModel(MealModel $model)
374
	{
375
		$this->mealModel = $model;
376
377
		return $this;
378
	}
379
380
	/**
381
	 * @return MeetingModel
382
	 */
383
	protected function getMeetingModel()
384
	{
385
		return $this->meetingModel;
386
	}
387
388
	/**
389
	 * @param  MeetingModel $model
390
	 * @return $this
391
	 */
392
	protected function setMeetingModel(MeetingModel $model)
393
	{
394
		$this->meetingModel = $model;
395
396
		return $this;
397
	}
398
399
	/**
400
	 * @return VisitorModel
401
	 */
402
	protected function getVisitorModel()
403
	{
404
		return $this->visitorModel;
405
	}
406
407
	/**
408
	 * @param  VisitorModel $model
409
	 * @return $this
410
	 */
411
	protected function setVisitorModel(VisitorModel $model)
412
	{
413
		$this->visitorModel = $model;
414
415
		return $this;
416
	}
417
418
	/**
419
	 * @return ProgramRepository
420
	 */
421
	protected function getProgramRepository(): ProgramRepository
422
	{
423
		return $this->programRepository;
424
	}
425
426
	/**
427
	 * @param  ProgramRepository $repository
428
	 * @return $this
429
	 */
430
	protected function setProgramRepository(ProgramRepository $repository): self
431
	{
432
		$this->programRepository = $repository;
433
434
		return $this;
435
	}
436
437
	/**
438
	 * @return UserService
439
	 */
440
	protected function getUserService()
441
	{
442
		return $this->userService;
443
	}
444
445
	/**
446
	 * @param  UserService $service
447
	 * @return $this
448
	 */
449
	protected function setUserService(UserService $service)
450
	{
451
		$this->userService = $service;
452
453
		return $this;
454
	}
455
456
	/**
457
	 * @return EventService
458
	 */
459
	protected function getEventService(): EventService
460
	{
461
		return $this->skautisEventService;
462
	}
463
464
	/**
465
	 * @param EventService $skautisEvent
0 ignored issues
show
Bug introduced by
There is no parameter named $skautisEvent. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
466
	 *
467
	 * @return self
468
	 */
469
	protected function setEventService(EventService $service): self
470
	{
471
		$this->skautisEventService = $service;
472
473
		return $this;
474
	}
475
476
477
	/**
478
	 * @return SettingsModel
479
	 */
480
	public function getSettingsModel()
481
	{
482
		return $this->settingsModel;
483
	}
484
485
	/**
486
	 * @param SettingsModel $model
487
	 *
488
	 * @return self
489
	 */
490
	public function setSettingsModel(SettingsModel $model): self
491
	{
492
		$this->settingsModel = $model;
493
494
		return $this;
495
	}
496
497
}
498