Passed
Push — developer ( 1116b3...4a3269 )
by Radosław
34:20 queued 19:24
created

Settings_Groups_Delete_Action   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
c 0
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 4
1
<?php
2
/**
3
 * Settings groups delete action file.
4
 *
5
 * @package   Settings.Action
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
/**
13
 * Settings groups delete action class.
14
 */
15
class Settings_Groups_Delete_Action extends Settings_Vtiger_Delete_Action
16
{
17
	/** {@inheritdoc} */
18
	public function process(App\Request $request)
19
	{
20
		$recordId = $request->getInteger('record');
21
		$transferRecordId = $request->getInteger('transfer_record');
22
23
		$recordModel = Settings_Groups_Record_Model::getInstance($recordId);
24
		if (\App\User::isExists($transferRecordId)) {
25
			$transferToOwner = Users_Record_Model::getInstanceById($transferRecordId, 'Users');
26
		} else {
27
			$transferToOwner = Settings_Groups_Record_Model::getInstance($transferRecordId);
28
		}
29
		if ($recordModel && $transferToOwner) {
30
			$recordModel->delete($transferToOwner);
31
		}
32
33
		$response = new Vtiger_Response();
34
		$response->setResult(['success' => true]);
35
		$response->emit();
36
	}
37
}
38