Skip to content

Commit 569b82a

Browse files
committed
added passing event responses back, and removed the namespace param from the loader class, and added blank source handling to the add requirement metod
1 parent 436b32b commit 569b82a

1 file changed

Lines changed: 24 additions & 30 deletions

File tree

src/Loader.php

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,42 @@ public function get_setting($setting)
6868
* @param string $type route type client,admin,public,public_file,client_ajax,public_ajax,admin_ajax
6969
* @param string $function php function name or class.class_name
7070
* @param string $source php source file
71-
* @param string $namespace optional php namespace
7271
* @param string $base base path
7372
* @param mixed $methods request methods, string or array including get post put head patch etc..
7473
*/
75-
public function add_route_requirement($type, $function, $source, $namespace = '', $path = false, $methods = false)
74+
public function add_route_requirement($type, $function, $source, $path = false, $methods = false)
7675
{
7776
if ($path === false)
7877
$path = '/'.$function;
7978
if ($methods === false)
8079
$methods = ['GET', 'POST'];
81-
$this->routes[$path] = [$type, $namespace.$function, $methods];
82-
$this->add_requirement($function, $source, $namespace);
80+
$this->routes[$path] = [$type, $function, $methods];
81+
$this->add_requirement($function, $source);
8382
}
8483

8584
/**
8685
* adds a requirement into the loader and registers it as a page with the router
8786
*
8887
* @param string $function php function name or class.class_name
8988
* @param string $source php source file
90-
* @param string $namespace optional php namespace
9189
* @param mixed $methods request methods, string or array including get post put head patch etc..
9290
*/
93-
public function add_page_requirement($function, $source, $namespace = '', $methods = false)
91+
public function add_page_requirement($function, $source, $methods = false)
9492
{
95-
$this->add_route_requirement('client', $function, $source, $namespace, '/'.$function, $methods);
96-
$this->add_route_requirement('client', $function, $source, $namespace, '/admin/'.$function, $methods);
93+
$this->add_route_requirement('client', $function, $source, '/'.$function, $methods);
94+
$this->add_route_requirement('client', $function, $source, '/admin/'.$function, $methods);
9795
}
9896

9997
/**
10098
* adds a requirement into the loader and registers it as a page with the router
10199
*
102100
* @param string $function php function name or class.class_name
103101
* @param string $source php source file
104-
* @param string $namespace optional php namespace
105102
* @param mixed $methods request methods, string or array including get post put head patch etc..
106103
*/
107-
public function add_root_page_requirement($function, $source, $namespace = '', $methods = false)
104+
public function add_root_page_requirement($function, $source, $methods = false)
108105
{
109-
$this->add_route_requirement('client', $function, $source, $namespace, '/'.$function, $methods);
106+
$this->add_route_requirement('client', $function, $source, '/'.$function, $methods);
110107
}
111108

112109
/**
@@ -116,9 +113,9 @@ public function add_root_page_requirement($function, $source, $namespace = '', $
116113
* @param string $path source file path
117114
* @param mixed $methods request methods, string or array including get post put head patch etc..
118115
*/
119-
public function add_public_requirement($function, $source, $namespace = '', $methods = false)
116+
public function add_public_requirement($function, $source, $methods = false)
120117
{
121-
$this->add_route_requirement('public', $function, $source, $namespace, '/'.$function, $methods);
118+
$this->add_route_requirement('public', $function, $source, '/'.$function, $methods);
122119
}
123120

124121
/**
@@ -138,66 +135,63 @@ public function add_public_file($function, $source, $methods = false)
138135
*
139136
* @param string $function php function name or class.class_name
140137
* @param string $source php source file
141-
* @param string $namespace optional php namespace
142138
* @param mixed $methods request methods, string or array including get post put head patch etc..
143139
*/
144-
public function add_ajax_page_requirement($function, $source, $namespace = '', $methods = false)
140+
public function add_ajax_page_requirement($function, $source, $methods = false)
145141
{
146-
$this->add_route_requirement('client_ajax', $function, $source, $namespace, '/ajax/'.$function, $methods);
147-
$this->add_route_requirement('client_ajax', $function, $source, $namespace, '/admin/ajax/'.$function, $methods);
142+
$this->add_route_requirement('client_ajax', $function, $source, '/ajax/'.$function, $methods);
143+
$this->add_route_requirement('client_ajax', $function, $source, '/admin/ajax/'.$function, $methods);
148144
}
149145

150146
/**
151147
* adds a requirement into the loader and registers it as a page with the router
152148
*
153149
* @param string $function php function name or class.class_name
154150
* @param string $source php source file
155-
* @param string $namespace optional php namespace
156151
* @param mixed $methods request methods, string or array including get post put head patch etc..
157152
*/
158-
public function add_api_page_requirement($function, $source, $namespace = '', $methods = false)
153+
public function add_api_page_requirement($function, $source, $methods = false)
159154
{
160-
$this->add_route_requirement('client_api', $function, $source, $namespace, '/apiv2/'.$function, $methods);
161-
$this->add_route_requirement('client_api', $function, $source, $namespace, '/admin/apiv2/'.$function, $methods);
155+
$this->add_route_requirement('client_api', $function, $source, '/apiv2/'.$function, $methods);
156+
$this->add_route_requirement('client_api', $function, $source, '/admin/apiv2/'.$function, $methods);
162157
}
163158

164159
/**
165160
* adds a requirement into the loader and registers it as a page with the router
166161
*
167162
* @param string $function php function name or class.class_name
168163
* @param string $source php source file
169-
* @param string $namespace optional php namespace
170164
* @param mixed $methods request methods, string or array including get post put head patch etc..
171165
*/
172-
public function add_apmin_api_page_requirement($function, $source, $namespace = '', $methods = false)
166+
public function add_apmin_api_page_requirement($function, $source, $methods = false)
173167
{
174-
$this->add_route_requirement('admin_api', $function, $source, $namespace, '/admin/ajax/'.$function, $methods);
168+
$this->add_route_requirement('admin_api', $function, $source, '/admin/ajax/'.$function, $methods);
175169
}
176170

177171
/**
178172
* adds a requirement into the loader and registers it as a page with the router
179173
*
180174
* @param string $function php function name or class.class_name
181175
* @param string $source php source file
182-
* @param string $namespace optional php namespace
183176
* @param mixed $methods request methods, string or array including get post put head patch etc..
184177
*/
185-
public function add_admin_page_requirement($function, $source, $namespace = '', $methods = false)
178+
public function add_admin_page_requirement($function, $source, $methods = false)
186179
{
187-
$this->add_route_requirement('admin', $function, $source, $namespace, '/admin/'.$function, $methods);
180+
$this->add_route_requirement('admin', $function, $source, '/admin/'.$function, $methods);
188181
}
189182

190183
/**
191184
* adds a requirement into the loader
192185
*
193186
* @param string $function php function name or class.class_name
194187
* @param string $source php source file
195-
* @param string $namespace optional php namespace
196188
* @param mixed $methods request methods, string or array including get post put head patch etc..
197189
*/
198-
public function add_requirement($function, $source, $namespace = '', $methods = false)
190+
public function add_requirement($function, $source, $methods = false)
199191
{
200-
$this->requirements[$function] = $namespace.$source;
192+
if ($source != '') {
193+
$this->requirements[$function] = $source;
194+
}
201195
}
202196

203197
/**

0 commit comments

Comments
 (0)