Completed
Push — master ( 3c2ce2...009b85 )
by Derek Stephen
05:24
created

AbstractController::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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
}