1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Blitz PHP framework. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the LICENSE file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace BlitzPHP\Controllers; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Un contrôleur extensible pour fournir une API RESTful pour une ressource. |
16
|
|
|
*/ |
17
|
|
|
class ResourceController extends RestController |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Renvoie un tableau d'objets ressources, eux-mêmes au format tableau |
21
|
|
|
* |
22
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
23
|
|
|
*/ |
24
|
|
|
public function index() |
25
|
|
|
{ |
26
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Renvoyer les propriétés d'un objet ressource |
31
|
|
|
* |
32
|
|
|
* @param int|string|null $id |
33
|
|
|
* |
34
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
35
|
|
|
*/ |
36
|
|
|
public function show($id = null) |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Renvoie un nouvel objet ressource, avec les propriétés par défaut |
43
|
|
|
* |
44
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
45
|
|
|
*/ |
46
|
|
|
public function new() |
47
|
|
|
{ |
48
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Créer un nouvel objet ressource, à partir des données envoyées |
53
|
|
|
* |
54
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
55
|
|
|
*/ |
56
|
|
|
public function create() |
57
|
|
|
{ |
58
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Renvoyer les propriétés modifiables d'un objet ressource |
63
|
|
|
* |
64
|
|
|
* @param int|string|null $id |
65
|
|
|
* |
66
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
67
|
|
|
*/ |
68
|
|
|
public function edit($id = null) |
|
|
|
|
69
|
|
|
{ |
70
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Ajouter ou mettre à jour une ressource de modèle, à partir de données envoyées |
75
|
|
|
* |
76
|
|
|
* @param int|string|null $id |
77
|
|
|
* |
78
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
79
|
|
|
*/ |
80
|
|
|
public function update($id = null) |
|
|
|
|
81
|
|
|
{ |
82
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Supprimer l'objet ressource désigné du modèle |
87
|
|
|
* |
88
|
|
|
* @param int|string|null $id |
89
|
|
|
* |
90
|
|
|
* @return \Psr\Http\Message\ResponseInterface|string|void |
91
|
|
|
*/ |
92
|
|
|
public function delete($id = null) |
|
|
|
|
93
|
|
|
{ |
94
|
|
|
return $this->respondNotImplemented($this->_translate('notImplemented', [__METHOD__])); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Définir/modifier la représentation de réponse attendue pour les objets renvoyés |
99
|
|
|
* |
100
|
|
|
* @param string $format json/xml |
101
|
|
|
* |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
|
public function setFormat(string $format = 'json') |
105
|
|
|
{ |
106
|
|
|
if (in_array($format, ['json', 'xml'], true)) { |
107
|
|
|
$this->returnFormat($format); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.