class Customer {
function GET($resource_id = Null) {
}
// POST is a demux (yeah, I was into electronics)
function POST() {
if (isset($POST['_method']) && is_valid_emulated_method($POST['_method'])) {
$method = $POST['_method'];
return $this->$method(get_emulated_param());
}
return $this->_POST();
}
// Original POST operation
function _POST() {
// add new customer
}
function PUT($id) {
// modify customer
}
function DELETE($id) {
// delete customer
}
}
Comments
Aliasing (aka demux), ala Rails.
Consider that:
can be emulated and equivalent to
This is similar to drupal's clean_url implementation of
being the same as:
In code, it becomes:
class Customer { function GET($resource_id = Null) { } // POST is a demux (yeah, I was into electronics) function POST() { if (isset($POST['_method']) && is_valid_emulated_method($POST['_method'])) { $method = $POST['_method']; return $this->$method(get_emulated_param()); } return $this->_POST(); } // Original POST operation function _POST() { // add new customer } function PUT($id) { // modify customer } function DELETE($id) { // delete customer } }