Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Code Block
languagephp
title/plugins/foo_bar/models/foo_bar_sprocket.php
firstline1
linenumberstrue
<?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 URIs, respectively:

No Format
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

All private and protected methods are inaccessible to the API.