├── tests
├── PresenterTest
│ └── test.php
├── fixtures
│ └── image.jpg
├── ActionTest
│ └── Action.php
├── ActionFactoryTest.php
├── ExceptionTest.php
├── EventHandlers
│ └── DispatchErrorHandlerTest.php
├── ActionTest.php
├── PresenterTest.php
└── DispatchTest.php
├── src
├── EventDispatcher.php
├── EventHandlers
│ ├── EventHandlerInterface.php
│ └── DispatchErrorHandler.php
├── Exceptions
│ ├── DispatchException.php
│ ├── ExitDispatchException.php
│ ├── PageNotFoundException.php
│ ├── NotAuthorizedException.php
│ └── ActionNotFoundException.php
├── ActionFactoryInterface.php
├── DispatchEvents.php
├── PresenterInterface.php
├── ActionFactory.php
├── ActionInterface.php
├── Events
│ ├── PreDispatchEvent.php
│ ├── PostDispatchEvent.php
│ ├── DispatchErrorEvent.php
│ ├── PrePresentEvent.php
│ └── PostPresentEvent.php
├── Action.php
├── Config
│ └── Common.php
├── Presenter.php
├── Exception.php
└── Dispatch.php
├── .travis.yml
├── composer.json
├── phpunit.xml
├── LICENSE
├── .gitignore
└── README.md
/tests/PresenterTest/test.php:
--------------------------------------------------------------------------------
1 | Sup, =$data['name']?>?
2 |
--------------------------------------------------------------------------------
/tests/fixtures/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aolarchive/atc/HEAD/tests/fixtures/image.jpg
--------------------------------------------------------------------------------
/src/EventDispatcher.php:
--------------------------------------------------------------------------------
1 | 'error', 'message' => 'internal error'];
10 | protected $http_code = 500;
11 | protected $view = 'errors/500';
12 | }
13 |
--------------------------------------------------------------------------------
/src/Exceptions/ExitDispatchException.php:
--------------------------------------------------------------------------------
1 | 'error', 'message' => 'page not found'];
10 | protected $http_code = 404;
11 | protected $view = 'errors/404';
12 | }
13 |
--------------------------------------------------------------------------------
/src/Exceptions/NotAuthorizedException.php:
--------------------------------------------------------------------------------
1 | 'error', 'message' => 'not authorized'];
10 | protected $http_code = 401;
11 | protected $view = 'errors/401';
12 | }
13 |
--------------------------------------------------------------------------------
/src/ActionFactoryInterface.php:
--------------------------------------------------------------------------------
1 | params;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Exceptions/ActionNotFoundException.php:
--------------------------------------------------------------------------------
1 | 'error', 'message' => 'internal error - action not found'];
11 | protected $http_code = 500;
12 | protected $view = 'errors/500';
13 | }
14 |
--------------------------------------------------------------------------------
/src/DispatchEvents.php:
--------------------------------------------------------------------------------
1 | 'bar'];
13 | $factory = new ActionFactory('Aol\\Atc\\Tests\\ActionTest\\');
14 |
15 | /** @var Action $action */
16 | $action = $factory->newInstance('Action', $params);
17 |
18 | $this->assertInstanceOf('Aol\Atc\ActionInterface', $action);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/ActionFactory.php:
--------------------------------------------------------------------------------
1 | namespace = $namespace;
12 | }
13 |
14 | /**
15 | * @inheritdoc
16 | */
17 | public function newInstance($action, $params)
18 | {
19 | $class = $this->parseAction($action);
20 | if (!is_null($class)) {
21 | $class = new $class($params);
22 | }
23 |
24 | return $class;
25 | }
26 |
27 | /**
28 | * @param string $action
29 | * @return string
30 | */
31 | protected function parseAction($action)
32 | {
33 | $class = $this->namespace . str_replace('.', '\\', $action);
34 | $class = class_exists($class) ? $class : null;
35 |
36 | return $class;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "aol/atc",
3 | "description": "ATC is a small dispatching library for PHP built on Aura.Router and Symfony's HTTP Foundation",
4 | "license": "MIT",
5 | "authors": [
6 | {
7 | "name": "Jake A. Smith",
8 | "email": "theman@jakeasmith.com"
9 | },
10 | {
11 | "name": "Samantha Quiñones",
12 | "email": "samantha@tembies.com"
13 | }
14 | ],
15 | "minimum-stability": "stable",
16 | "require": {
17 | "aura/accept": "~2.0",
18 | "aura/router": "~2.0",
19 | "psr/log": "~1.0",
20 | "symfony/http-foundation": "~2.5",
21 | "symfony/event-dispatcher": "~2.6"
22 | },
23 | "require-dev": {
24 | "phpunit/phpunit": "~4.3",
25 | "mockery/mockery": "~0.9",
26 | "aura/di": "~2.0"
27 | },
28 | "autoload": {
29 | "psr-4": {
30 | "Aol\\Atc\\": "src/",
31 | "Aol\\Atc\\Tests\\": "tests/"
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/ActionInterface.php:
--------------------------------------------------------------------------------
1 |
2 |