You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Plugins may extend the API simply by offering public model methods. Take for example a plugin called FooBar. The FooBar plugin may have the following model:

/plugins/foo_bar/models/foo_bar_sprocket.php
<?php
class FooBarSprocket extends FooBarModel {
 
 public function create(array $vars) {
 
 }
 
 public function delete($sprocket_id) {
 
 }
 
 private function calculateCost($sprocket_id) {
 
 }
}
?>

FooBarSprocket offers two public methods and one private method. Both FooBarSprocket::create() and FooBarSprocket::delete() are made available via the API at the following URLs, respectively:

https://yourdomain.com/installpath/index.php/api/foo_bar.foo_bar_sprocket/create.json?vars[price]=1.99
https://yourdomain.com/installpath/index.php/api/foo_bar.foo_bar_sprocket/delete.json?sprocket_id=123

The API respects your authority

Only public model methods are accessible via the API.
  • No labels