Skip to content

Commit 524718b

Browse files
committed
namespace fixes
1 parent 8d53634 commit 524718b

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

application/controllers/api/Example.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @license MIT
1818
* @link https://github.com/chriskacerguis/codeigniter-restserver
1919
*/
20-
class Example extends REST_Controller {
20+
class Example extends \Restserver\Libraries\REST_Controller {
2121

2222
function __construct()
2323
{
@@ -50,15 +50,15 @@ public function users_get()
5050
if ($users)
5151
{
5252
// Set the response and exit
53-
$this->response($users, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
53+
$this->response($users, \Restserver\Libraries\REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
5454
}
5555
else
5656
{
5757
// Set the response and exit
5858
$this->response([
5959
'status' => FALSE,
6060
'message' => 'No users were found'
61-
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
61+
], \Restserver\Libraries\REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
6262
}
6363
}
6464

@@ -70,7 +70,7 @@ public function users_get()
7070
if ($id <= 0)
7171
{
7272
// Invalid id, set the response and exit.
73-
$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
73+
$this->response(NULL, \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
7474
}
7575

7676
// Get the user from the array, using the id as key for retrieval.
@@ -91,14 +91,14 @@ public function users_get()
9191

9292
if (!empty($user))
9393
{
94-
$this->set_response($user, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
94+
$this->set_response($user, \Restserver\Libraries\REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
9595
}
9696
else
9797
{
9898
$this->set_response([
9999
'status' => FALSE,
100100
'message' => 'User could not be found'
101-
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
101+
], \Restserver\Libraries\REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
102102
}
103103
}
104104

@@ -112,7 +112,7 @@ public function users_post()
112112
'message' => 'Added a resource'
113113
];
114114

115-
$this->set_response($message, REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
115+
$this->set_response($message, \Restserver\Libraries\REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
116116
}
117117

118118
public function users_delete()
@@ -123,7 +123,7 @@ public function users_delete()
123123
if ($id <= 0)
124124
{
125125
// Set the response and exit
126-
$this->response(NULL, REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
126+
$this->response(NULL, \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
127127
}
128128

129129
// $this->some_model->delete_something($id);
@@ -132,7 +132,7 @@ public function users_delete()
132132
'message' => 'Deleted the resource'
133133
];
134134

135-
$this->set_response($message, REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
135+
$this->set_response($message, \Restserver\Libraries\REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
136136
}
137137

138138
}

application/controllers/api/Key.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @license MIT
1818
* @link https://github.com/chriskacerguis/codeigniter-restserver
1919
*/
20-
class Key extends REST_Controller {
20+
class Key extends \Restserver\Libraries\REST_Controller {
2121

2222
protected $methods = [
2323
'index_put' => ['level' => 10, 'limit' => 10],
@@ -47,14 +47,14 @@ public function index_put()
4747
$this->response([
4848
'status' => TRUE,
4949
'key' => $key
50-
], REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
50+
], \Restserver\Libraries\REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
5151
}
5252
else
5353
{
5454
$this->response([
5555
'status' => FALSE,
5656
'message' => 'Could not save the key'
57-
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
57+
], \Restserver\Libraries\REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
5858
}
5959
}
6060

@@ -75,7 +75,7 @@ public function index_delete()
7575
$this->response([
7676
'status' => FALSE,
7777
'message' => 'Invalid API key'
78-
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
78+
], \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
7979
}
8080

8181
// Destroy it
@@ -85,7 +85,7 @@ public function index_delete()
8585
$this->response([
8686
'status' => TRUE,
8787
'message' => 'API key was deleted'
88-
], REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
88+
], \Restserver\Libraries\REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
8989
}
9090

9191
/**
@@ -106,7 +106,7 @@ public function level_post()
106106
$this->response([
107107
'status' => FALSE,
108108
'message' => 'Invalid API key'
109-
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
109+
], \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
110110
}
111111

112112
// Update the key level
@@ -115,14 +115,14 @@ public function level_post()
115115
$this->response([
116116
'status' => TRUE,
117117
'message' => 'API key was updated'
118-
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
118+
], \Restserver\Libraries\REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
119119
}
120120
else
121121
{
122122
$this->response([
123123
'status' => FALSE,
124124
'message' => 'Could not update the key level'
125-
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
125+
], \Restserver\Libraries\REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
126126
}
127127
}
128128

@@ -143,7 +143,7 @@ public function suspend_post()
143143
$this->response([
144144
'status' => FALSE,
145145
'message' => 'Invalid API key'
146-
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
146+
], \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
147147
}
148148

149149
// Update the key level
@@ -152,14 +152,14 @@ public function suspend_post()
152152
$this->response([
153153
'status' => TRUE,
154154
'message' => 'Key was suspended'
155-
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
155+
], \Restserver\Libraries\REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
156156
}
157157
else
158158
{
159159
$this->response([
160160
'status' => FALSE,
161161
'message' => 'Could not suspend the user'
162-
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
162+
], \Restserver\Libraries\REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
163163
}
164164
}
165165

@@ -181,7 +181,7 @@ public function regenerate_post()
181181
$this->response([
182182
'status' => FALSE,
183183
'message' => 'Invalid API key'
184-
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
184+
], \Restserver\Libraries\REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
185185
}
186186

187187
// Build a new key
@@ -196,14 +196,14 @@ public function regenerate_post()
196196
$this->response([
197197
'status' => TRUE,
198198
'key' => $new_key
199-
], REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
199+
], \Restserver\Libraries\REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
200200
}
201201
else
202202
{
203203
$this->response([
204204
'status' => FALSE,
205205
'message' => 'Could not save the key'
206-
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
206+
], \Restserver\Libraries\REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
207207
}
208208
}
209209

application/libraries/Format.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace Restserver\Libraries;
2+
// Note, this cannot be namespaced for the time being due to how CI works
3+
//namespace Restserver\Libraries;
34

45
defined('BASEPATH') OR exit('No direct script access allowed');
56

0 commit comments

Comments
 (0)