-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResourceController.php
executable file
·110 lines (98 loc) · 2.39 KB
/
ResourceController.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace CodeIgniter\RESTful;
use CodeIgniter\API\ResponseTrait;
/**
* An extendable controller to provide a RESTful API for a resource.
*/
class ResourceController extends BaseResource
{
use ResponseTrait;
/**
* Return an array of resource objects, themselves in array format
*
* @return mixed
*/
public function index()
{
return $this->fail(lang('RESTful.notImplemented', ['index']), 501);
}
/**
* Return the properties of a resource object
*
* @param mixed $id
*
* @return mixed
*/
public function show($id = null)
{
return $this->fail(lang('RESTful.notImplemented', ['show']), 501);
}
/**
* Return a new resource object, with default properties
*
* @return mixed
*/
public function new()
{
return $this->fail(lang('RESTful.notImplemented', ['new']), 501);
}
/**
* Create a new resource object, from "posted" parameters
*
* @return mixed
*/
public function create()
{
return $this->fail(lang('RESTful.notImplemented', ['create']), 501);
}
/**
* Return the editable properties of a resource object
*
* @param mixed $id
*
* @return mixed
*/
public function edit($id = null)
{
return $this->fail(lang('RESTful.notImplemented', ['edit']), 501);
}
/**
* Add or update a model resource, from "posted" properties
*
* @param mixed $id
*
* @return mixed
*/
public function update($id = null)
{
return $this->fail(lang('RESTful.notImplemented', ['update']), 501);
}
/**
* Delete the designated resource object from the model
*
* @param mixed $id
*
* @return mixed
*/
public function delete($id = null)
{
return $this->fail(lang('RESTful.notImplemented', ['delete']), 501);
}
/**
* Set/change the expected response representation for returned objects
*/
public function setFormat(string $format = 'json')
{
if (in_array($format, ['json', 'xml'], true)) {
$this->format = $format;
}
}
}