AbstractController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 45
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A getContainerObject() 0 4 1
A sendJSONResponse() 0 7 1
A getIdentity() 0 7 2
A getRequest() 0 4 1
1
<?php
2
3
namespace Del\Common\ZF1\Controller;
4
5
use Del\Common\ContainerService;
6
use Exception;
7
use Zend_Auth;
8
use Zend_Controller_Action;
9
use Zend_Layout;
10
11
class AbstractController extends Zend_Controller_Action
12
{
13
    protected $container;
14
15
    public function init()
16
    {
17
        $this->container = ContainerService::getInstance()->getContainer();
18
    }
19
20
    /**
21
     * @param $key
22
     * @return mixed
23
     */
24
    public function getContainerObject($key)
25
    {
26
        return $this->container[$key];
27
    }
28
29
    /**
30
     *
31
     */
32
    public function sendJSONResponse(array $array)
33
    {
34
        Zend_Layout::getMvcInstance()->disableLayout();
35
        $this->_helper->viewRenderer->setNoRender();
36
        $this->getResponse()->setHeader('Content-Type', 'application/json');
37
        $this->_helper->json($array);
38
    }
39
40
    public function getIdentity()
41
    {
42
        if(Zend_Auth::getInstance()->hasIdentity()) {
43
            return Zend_Auth::getInstance()->getIdentity();
44
        }
45
        throw new Exception('No Identity.');
46
    }
47
48
    /**
49
     * @return Zend_Controller_Request_Http
50
     */
51
    public function getRequest()
52
    {
53
        return parent::getRequest();
54
    }
55
}