-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoute.php
78 lines (65 loc) · 1.66 KB
/
Route.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace Steel;
use Steel\Interfaces\Route as IRoute;
/**
* Route
*/
class Route implements IRoute
{
const EXCEPTION_MISSING_ENTITY_OR_ACTION = 'Missing entity (%s) or action (%s).';
const EXCEPTION_ENTITY_METHOD_NOT_FOUND = '%s::%s not found!';
use Injectors\Config;
/**
* @var string
*/
protected $entity;
/**
* @var string
*/
protected $action;
/**
* Constructor
*
* @param string $entity Entities name
* @param string $action Actions name
*/
public function __construct($entity, $action)
{
if (empty( $entity ) || empty( $action )) {
throw new \InvalidArgumentException( sprintf(self::EXCEPTION_MISSING_ENTITY_OR_ACTION, $entity, $action) );
} else {
$this->entity = $entity;
$this->action = $action;
}
}
/**
* @throws \Exception
*/
public function follow()
{
$class = $this->entity;
$method = $this->action;
if (class_exists($class)) {
$entity = new $class();
if (!method_exists($entity, $method)) {
throw new \RuntimeException( sprintf(
self::EXCEPTION_ENTITY_METHOD_NOT_FOUND,
$entity,
$method
) );
}
$entity->$method();
}
}
protected function parseRouteDetails( $route, &$routeData )
{
var_dump('route', $route);
$routeData[(string)$route->path] = $route;
}
/**
* @param Interfaces\Config $config
*/
protected function findRouteInConfig(Interfaces\Config $config)
{
}
}