This is an example of actions for Vivvo's Comments.
$service_definition = array( "comment.add" => array( "function" => "comment_service", "signature" => array(array('bool', 'string','integer')), "docstring" => 'Add new comment.' ), ... "comment.vote" => array( "function" => "comment_service", "signature" => array(array('bool', 'ineteger', 'ineteger')), "docstring" => 'Vote' ) ); function comment_service(&$sm, $action, $command){ require_once(dirname(__FILE__) . '/Comments.service.php'); $comment_service =& new comment_service($sm); $um =& $sm->get_url_manager(); $dm =& $sm->get_dump_manager(); $lang =& $sm->get_lang(); if ($command == 'add'){ $in_comment = $um->get_param_regexp('/^COMMENT_/'); $captcha = $um->get_param('COMMENT_captcha'); $response = $comment_service->add_comment($in_comment, $captcha); if ($response){ $dm->add_dump('info', 0 , $lang->get_value('LNG_INFO_COMMENT_ADD_SUCCESS')); return true; }else{ return false; } ... }elseif($command == 'vote'){ $comment_id = $um->get_param('COMMENT_id'); $vote = $um->get_param('COMMENT_vote'); $response = $comment_service->vote($comment_id, $vote); if ($response){ return true; }else{ return false; } } return true; }
Array $service_definition contains list of commands. Name of command in this array contains two word. First word is action and second word is command. Each name has information about main function, signature and docstring. Vivvo detects all $service_definition and if find action which user