Passed
Pull Request — developer (#17138)
by
unknown
18:27
created

Calendar_RepeatEvents_Handler   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 28
c 1
b 0
f 0
dl 0
loc 64
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A editViewPreSave() 0 13 3
A preStateChange() 0 13 3
A preDelete() 0 13 3
1
<?php
2
/**
3
 * Select saving mode when event is repeat handler.
4
 *
5
 * @package Handler
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Adrian Kon <[email protected]>
10
 */
11
/**
12
 * Calendar_RepeatEvents_Handler class.
13
 */
14
class Calendar_RepeatEvents_Handler
15
{
16
	/**
17
	 * EditViewPreSave handler function.
18
	 *
19
	 * @param App\EventHandler $eventHandler
20
	 */
21
	public function editViewPreSave(App\EventHandler $eventHandler)
22
	{
23
		$response = ['result' => true];
24
		$recordModel = $eventHandler->getRecordModel();
25
		$request = \App\Request::init();
26
		if ($recordModel->get('reapeat') && $request->isEmpty('typeSaving')) {
27
			$response = [
28
				'result' => false,
29
				'type' => 'modal',
30
				'url' => 'index.php?module=Calendar&view=RepeatEvents',
31
			];
32
		}
33
		return $response;
34
	}
35
36
	/**
37
	 * Pre delete handler function.
38
	 *
39
	 * @param App\EventHandler $eventHandler
40
	 *
41
	 * @return array
42
	 */
43
	public function preDelete(App\EventHandler $eventHandler)
44
	{
45
		$response = ['result' => true];
46
		$recordModel = $eventHandler->getRecordModel();
47
		$request = \App\Request::init();
48
		if ($recordModel->get('reapeat') && $request->isEmpty('typeSaving')) {
49
			$response = [
50
				'result' => false,
51
				'type' => 'modal',
52
				'url' => 'index.php?module=Calendar&view=RepeatEventsDelete',
53
			];
54
		}
55
		return $response;
56
	}
57
58
	/**
59
	 * Register pre state change.
60
	 *
61
	 * @param App\EventHandler $eventHandler
62
	 *
63
	 * @return array
64
	 */
65
	public function preStateChange(App\EventHandler $eventHandler)
66
	{
67
		$response = ['result' => true];
68
		$recordModel = $eventHandler->getRecordModel();
69
		$request = \App\Request::init();
70
		if ($recordModel->get('reapeat') && $request->isEmpty('typeSaving')) {
71
			$response = [
72
				'result' => false,
73
				'type' => 'modal',
74
				'url' => 'index.php?module=Calendar&view=RepeatEventsDelete',
75
			];
76
		}
77
		return $response;
78
	}
79
}
80