EditCities   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 3
A doActions() 0 2 1
A addNotices() 0 5 2
1
<?php
2
/**
3
 * Edit cities page controller class file
4
 *
5
 * @package    EBloodBank
6
 * @subpackage Controllers
7
 * @since      1.0
8
 */
9
namespace EBloodBank\Controllers;
10
11
use EBloodBank\Notices;
12
13
/**
14
 * Edit cities page controller class
15
 *
16
 * @since 1.0
17
 */
18
class EditCities extends ViewCities
19
{
20
    /**
21
     * @return void
22
     * @since 1.0
23
     */
24
    public function __invoke()
25
    {
26
        if ($this->hasAuthenticatedUser() && $this->getAcl()->isUserAllowed($this->getAuthenticatedUser(), 'City', 'edit')) {
27
            $this->doActions();
28
            $this->addNotices();
29
            $view = $this->viewFactory->forgeView('edit-cities', [
30
                'cities' => $this->getQueriedCities(),
31
                'pagination.total' => $this->getPagesTotal(),
32
                'pagination.current' => $this->getCurrentPage(),
33
            ]);
34
        } else {
35
            $view = $this->viewFactory->forgeView('error-403');
36
        }
37
        $view();
38
    }
39
40
    /**
41
     * @return void
42
     * @since 1.0
43
     */
44
    protected function doActions()
45
    {
46
    }
47
48
    /**
49
     * @return void
50
     * @since 1.0
51
     */
52
    protected function addNotices()
53
    {
54
        if (filter_has_var(INPUT_GET, 'flag-deleted')) {
55
            $deleted = (int) filter_input(INPUT_GET, 'flag-deleted');
56
            Notices::addNotice('deleted', sprintf(n__('%d city permanently deleted.', '%d cities permanently deleted.', $deleted), $deleted), 'success');
57
        }
58
    }
59
}
60