1 | <?php |
||
27 | trait ResourceCollectorTrait |
||
28 | { |
||
29 | |||
30 | abstract public function set($method, $pattern, $action); |
||
31 | |||
32 | /** |
||
33 | * A map of all routes of resources. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | |||
38 | protected $map = [ |
||
39 | "index" => ["get", "/{name}"], |
||
40 | "make" => ["get", "/{name}/make"], |
||
41 | "create" => ["post", "/{name}"], |
||
42 | "show" => ["get", "/{name}/{id:int+}"], |
||
43 | "edit" => ["get", "/{name}/{id:int+}/edit"], |
||
44 | "update" => ["put", "/{name}/{id:int+}"], |
||
45 | "delete" => ["delete", "/{name}/{id:int+}"], |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. |
||
50 | * Instead of declaring separate routes for your index, show, new, edit, create, update and destroy actions, |
||
51 | * a resourceful route declares them in a single line of code. |
||
52 | * |
||
53 | * @param string $controller The controller name. |
||
54 | * @param array $options Some options like, "as" to name the route pattern, "only" to |
||
55 | * explicit say that only this routes will be registered, and |
||
56 | * "except" that register all the routes except the indicates. |
||
57 | * @return RouteResource |
||
58 | */ |
||
59 | |||
60 | 9 | public function resource($controller, array $options = array()) |
|
73 | |||
74 | /** |
||
75 | * Collect several resources at same time. |
||
76 | * |
||
77 | * @param array $controllers Several controller names as parameters or an array with all controller names. |
||
78 | * @return RouteResource |
||
79 | */ |
||
80 | |||
81 | 1 | public function resources(array $controllers) |
|
88 | |||
89 | /** |
||
90 | * @param string $controller |
||
91 | * @param array $options |
||
92 | * |
||
93 | * @return mixed |
||
94 | */ |
||
95 | |||
96 | 9 | protected function getResourceName($controller, array $options) |
|
100 | |||
101 | /** |
||
102 | * @param array $options |
||
103 | * @return array |
||
104 | */ |
||
105 | |||
106 | 9 | protected function getResourceActions(array $options) |
|
111 | |||
112 | /** |
||
113 | * @param string $action |
||
114 | * @param string $path |
||
115 | * @param string $name |
||
116 | * @param string[] $options |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | |||
121 | 9 | protected function getResourcePath($action, $path, $name, array $options) |
|
127 | |||
128 | } |
||
129 |