DeactivateOperation::get_controls()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Icybee package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Icybee\Modules\Users\Operation;
13
14
use ICanBoogie\ErrorCollection;
15
use ICanBoogie\Operation;
16
17
use Icybee\Modules\Users\Module;
18
use Icybee\Modules\Users\User;
19
20
/**
21
 * Disables a user account.
22
 *
23
 * @property User $record
24
 */
25 View Code Duplication
class DeactivateOperation extends Operation
26
{
27
	/**
28
	 * @inheritdoc
29
	 */
30
	protected function get_controls()
31
	{
32
		return [
33
34
			self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER,
35
			self::CONTROL_RECORD => true,
36
			self::CONTROL_OWNERSHIP => true
37
38
		] + parent::get_controls();
39
	}
40
41
	/**
42
	 * @inheritdoc
43
	 */
44
	protected function validate(ErrorCollection $errors)
45
	{
46
		return true;
47
	}
48
49
	/**
50
	 * @inheritdoc
51
	 */
52
	protected function process()
53
	{
54
		$record = $this->record;
55
		$record->is_activated = false;
56
		$record->save();
57
58
		$this->response->message = $this->format('!name account is deactivated.', [
59
60
			'!name' => $record->name
61
62
		]);
63
64
		return true;
65
	}
66
}
67