1: <?php
2:
3: namespace Deimos\Controller;
4:
5: use Deimos\Builder\Builder;
6: use Deimos\Controller\Exceptions\ControllerNotFound;
7: use Deimos\Controller\Traits\Request;
8:
9: abstract class Processor extends Builder
10: {
11:
12: use Request;
13:
14: 15: 16:
17: protected $attribute = 'controller';
18:
19: 20: 21: 22: 23: 24: 25:
26: public function __construct(Builder $builder)
27: {
28: if ($builder instanceof self)
29: {
30: throw new \InvalidArgumentException('Instanceof SELF');
31: }
32:
33: $this->builder = $builder;
34: }
35:
36: 37: 38: 39: 40: 41: 42: 43:
44: public function execute()
45: {
46: $name = $this->request()->attribute($this->attribute);
47:
48: if ($this->methodExists($name))
49: {
50: 51: 52:
53: $instance = $this->instance($name);
54:
55: return $instance->execute();
56: }
57:
58: throw new ControllerNotFound('Controller \'' . $name . '\' not found!');
59: }
60:
61: }