This is a test site. Any changes will be lost!

Development:Moodle API

From MoodleDocs
Revision as of 07:45, 5 November 2008 by jerome mouneyrac (talk | contribs) (New page: {{Template:Work in progress}} =Introduction= This document is about the Moodle API introduced in Moodle 2.0. In order to be available more widely, Moodle 2.0 relocate core functions into d...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: This article is a work in progress. Please use the page comments for any recommendations/suggestions for improvement.


Introduction

This document is about the Moodle API introduced in Moodle 2.0. In order to be available more widely, Moodle 2.0 relocate core functions into different api.php files, called Moodle API.
Thus, the new web services module will be able to provide all of these functions as services. Moreover it would centralize core function into known location reducing code redundancy, bugs and maintenance time. With the time going, more of the core functions should end up into Moodle API.

How to

create a new API file

A new api.php file should be created into each module/block folder, and also the current admin/user/course/... common moodle folders. This file should contains a class named from the module: "class mod_forum_api", "class user_api", "class course_api"... Into this class, static function will provide requested information and operation: get(), update(), create(), delete(), ...

Define an API

The web services need to know what parameter are needed and what information are returned. So we need a way to generate this information.
TO BE DEFINED: have a look at PHPdoc if we can generate all needed information from the documentation

use it

These functions are called inside Moodle by the modules, block and others plugin, and also web services module. As they are static function, they should be called as:

   mod_forum_api::get_discussions
   user_api::update
   course_api::get_course
   ...


Functions List