1 | <?php |
||
22 | trait ResourceCollectorTrait |
||
23 | { |
||
24 | |||
25 | abstract public function set($method, $pattern, $action); |
||
26 | |||
27 | /** |
||
28 | * A map of all routes of resources. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | |||
33 | protected $map = [ |
||
34 | "index" => ["get", "/{name}"], |
||
35 | "make" => ["get", "/{name}/make"], |
||
36 | "create" => ["post", "/{name}"], |
||
37 | "show" => ["get", "/{name}/{id:int+}"], |
||
38 | "edit" => ["get", "/{name}/{id:int+}/edit"], |
||
39 | "update" => ["put", "/{name}/{id:int+}"], |
||
40 | "delete" => ["delete", "/{name}/{id:int+}"], |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. |
||
45 | * Instead of declaring separate routes for your index, show, new, edit, create, update and destroy actions, |
||
46 | * a resourceful route declares them in a single line of code. |
||
47 | * |
||
48 | * @param string $controller The controller name. |
||
49 | * @param array $options Some options like, "as" to name the route pattern, "only" to |
||
50 | * explicit say that only this routes will be registered, and |
||
51 | * "except" that register all the routes except the indicates. |
||
52 | * @return Resource |
||
53 | */ |
||
54 | |||
55 | 8 | public function resource($controller, array $options = array()) |
|
68 | |||
69 | /** |
||
70 | * Collect several resources at same time. |
||
71 | * |
||
72 | * @param array $controllers Several controller names as parameters or an array with all controller names. |
||
73 | * @return Resource |
||
74 | */ |
||
75 | |||
76 | public function resources(array $controllers) |
||
83 | |||
84 | /** |
||
85 | * @param string $controller |
||
86 | * @param array $options |
||
87 | * |
||
88 | * @return mixed |
||
89 | */ |
||
90 | |||
91 | 8 | protected function getResourceName($controller, array $options) |
|
95 | |||
96 | /** |
||
97 | * @param array $options |
||
98 | * @return array |
||
99 | */ |
||
100 | |||
101 | 8 | protected function getResourceActions(array $options) |
|
106 | |||
107 | /** |
||
108 | * @param string $action |
||
109 | * @param string $path |
||
110 | * @param string $name |
||
111 | * @param string[] $options |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | |||
116 | 8 | protected function getResourcePath($action, $path, $name, array $options) |
|
122 | |||
123 | } |
||
124 |