Completed
Push — develop ( 031ed9...9561de )
by
unknown
09:21
created

RemoveController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 6
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B indexAction() 0 25 3
1
<?php
2
/**
3
 * @filesource
4
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
5
 * @license MIT
6
 * @author Miroslav Fedeleš <[email protected]>
7
 * @since 0.27
8
 */
9
namespace Auth\Controller;
10
11
use Auth\Entity\Status;
12
use Zend\Mvc\Controller\AbstractActionController;
13
use Auth\Dependency\Manager as Dependencies;
14
15
/**
16
 *
17
 * @author Miroslav Fedeleš <[email protected]>r
18
 * @author Mathias Gelhausen <[email protected]>
19
 * @since 0.27
20
 */
21
class RemoveController extends AbstractActionController
22
{
23
    /**
24
     * @var Dependencies
25
     */
26
    protected $dependencies;
27
28
    /**
29
     * @param Dependencies $dependencies
30
     */
31
    public function __construct(Dependencies $dependencies)
32
    {
33
        $this->dependencies = $dependencies;
34
    }
35
36
    public function indexAction()
37
    {
38
        /* @var \Auth\AuthenticationService $auth */
39
        $auth = $this->serviceLocator->get('AuthenticationService');
40
        $user = $auth->getUser();
41
        $error = false;
42
        
43
        if ($this->params()->fromPost('confirm'))
44
        {
45
            if ($this->dependencies->removeItems($user)) {
46
                $auth->clearIdentity();
47
                $user->setStatus(Status::INACTIVE);
48
                return $this->redirect()->toRoute('lang');
49
            } else {
50
                $error = true;
51
            }
52
        }
53
        
54
        return [
55
            'lists' => $this->dependencies->getLists(),
56
            'user' => $user,
57
            'limit' => 20,
58
            'error' => $error,
59
        ];
60
    }
61
}
62