Overview

Namespaces

  • Deimos
    • Controller
      • Exceptions
      • Traits
  • PHP

Classes

  • Deimos\Controller\Controller
  • Deimos\Controller\Processor
  • Deimos\Controller\Proxy

Interfaces

  • Throwable

Traits

  • Deimos\Controller\Traits\Request

Exceptions

  • Deimos\Controller\Exceptions\ControllerNotFound
  • Deimos\Controller\Exceptions\DisplayNone
  • Deimos\Controller\Exceptions\RequestNotFound
  • Exception
  • InvalidArgumentException
  • LogicException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: namespace Deimos\Controller;
 4: 
 5: use Deimos\Controller\Exceptions\DisplayNone;
 6: use Deimos\Controller\Exceptions\RequestNotFound;
 7: 
 8: abstract class Controller extends Proxy
 9: {
10: 
11:     /**
12:      * @return mixed
13:      *
14:      * @throws \InvalidArgumentException
15:      * @throws RequestNotFound
16:      * @throws DisplayNone
17:      */
18:     public function execute()
19:     {
20:         $this->configure();
21:         $this->before();
22: 
23:         $name = $this->request()->attribute('action');
24:         $data = $this->instance($name);
25: 
26:         $this->after($data);
27: 
28:         return $this->display($data);
29:     }
30: 
31:     /**
32:      * @inheritdoc
33:      *
34:      * @throws \InvalidArgumentException
35:      * @throws DisplayNone
36:      */
37:     protected function display($data)
38:     {
39:         if (is_string($data))
40:         {
41:             return $data;
42:         }
43: 
44:         if (is_array($data) || $data instanceof \stdClass)
45:         {
46:             return $this->helper()->json()->encode($data);
47:         }
48: 
49:         throw new DisplayNone('Undefined value \'' . $data . '\'');
50:     }
51: 
52: }
API documentation generated by ApiGen