Completed
Push — develop ( 633189...e5954b )
by
unknown
15:49
created

RemoveController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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
use Auth\AuthenticationService;
15
16
/**
17
 *
18
 * @author Miroslav Fedeleš <[email protected]>r
19
 * @author Mathias Gelhausen <[email protected]>
20
 * @since 0.27
21
 */
22
class RemoveController extends AbstractActionController
23
{
24
    /**
25
     * @var Dependencies
26
     */
27
    protected $dependencies;
28
    
29
    /**
30
     * @var AuthenticationService
31
     */
32
    protected $auth;
33
34
    /**
35
     * @param Dependencies $dependencies
36
     * @param AuthenticationService $auth
37
     */
38
    public function __construct(Dependencies $dependencies, AuthenticationService $auth)
39
    {
40
        $this->dependencies = $dependencies;
41
        $this->auth = $auth;
42
    }
43
44
    public function indexAction()
45
    {
46
        $user = $this->auth->getUser();
47
        $error = false;
48
        
49
        if ($this->params()->fromPost('confirm'))
50
        {
51
            if ($this->dependencies->removeItems($user)) {
52
                $this->auth->clearIdentity();
53
                $user->setStatus(Status::INACTIVE);
54
                return $this->redirect()->toRoute('lang');
55
            } else {
56
                $error = true;
57
            }
58
        }
59
        
60
        return [
61
            'lists' => $this->dependencies->getLists(),
62
            'user' => $user,
63
            'limit' => 20,
64
            'error' => $error,
65
        ];
66
    }
67
}
68