function _comment_resource_definition in Services 6.3
Same name and namespace in other branches
- 7.3 resources/comment_resource.inc \_comment_resource_definition()
@file Will define the comments resource for dealing with node comments
1 call to _comment_resource_definition()
- _services_core_resources in ./
services.resource_build.inc - Supplies the resource definitions for Drupal core data
File
- resources/
comment_resource.inc, line 8 - Will define the comments resource for dealing with node comments
Code
function _comment_resource_definition() {
if (!module_exists('comment')) {
return array();
}
return array(
'comment' => array(
'operations' => array(
'create' => array(
'help' => 'Creates a comment',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'callback' => '_comment_resource_create',
'access callback' => '_comment_resource_access',
'access arguments' => array(
'create',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'comment',
'type' => 'array',
'description' => 'The comment object',
'source' => 'data',
'optional' => FALSE,
),
),
),
'retrieve' => array(
'help' => 'Retrieves a comment',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'callback' => '_comment_resource_retrieve',
'access callback' => '_comment_resource_access',
'access arguments' => array(
'view',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'cid',
'type' => 'int',
'description' => 'The cid of the comment to retrieve.',
'source' => array(
'path' => '0',
),
'optional' => FALSE,
),
),
),
'update' => array(
'help' => 'Updates a comment',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'callback' => '_comment_resource_update',
'access callback' => '_comment_resource_access',
'access arguments' => array(
'edit',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'cid',
'optional' => FALSE,
'source' => array(
'path' => 0,
),
'type' => 'int',
'description' => 'The unique identifier for this comment.',
),
array(
'name' => 'data',
'type' => 'array',
'description' => 'The comment array with updated information',
'source' => 'data',
'optional' => FALSE,
),
),
),
'delete' => array(
'help' => 'Deletes a comment',
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'callback' => '_comment_resource_delete',
'access callback' => '_comment_resource_access',
'access arguments' => array(
'edit',
),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'cid',
'type' => 'int',
'description' => 'The id of the comment to delete',
'source' => array(
'path' => '0',
),
'optional' => FALSE,
),
),
),
'index' => array(
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'callback' => '_comment_resource_index',
'args' => array(
array(
'name' => 'page',
'optional' => TRUE,
'type' => 'int',
'description' => 'The zero-based index of the page to get, defaults to 0.',
'default value' => 0,
'source' => array(
'param' => 'page',
),
),
array(
'name' => 'fields',
'optional' => TRUE,
'type' => 'string',
'description' => 'The fields to get.',
'default value' => '*',
'source' => array(
'param' => 'fields',
),
),
array(
'name' => 'parameters',
'optional' => TRUE,
'type' => 'array',
'description' => 'Parameters',
'default value' => array(),
'source' => array(
'param' => 'parameters',
),
),
array(
'name' => 'pagesize',
'optional' => TRUE,
'type' => 'int',
'description' => 'Number of records to get per page.',
'default value' => variable_get('services_comment_index_page_size', 20),
'source' => array(
'param' => 'pagesize',
),
),
),
'access callback' => '_comment_resource_access',
'access arguments' => array(
'view',
),
'access arguments append' => TRUE,
),
),
'actions' => array(
'countAll' => array(
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'help' => t('This method returns the number of comments on a given node.'),
'access callback' => '_comment_resource_access',
'access arguments' => array(
'view',
),
'callback' => '_comment_resource_count_all',
'args' => array(
array(
'name' => 'nid',
'type' => 'int',
'description' => t('The node id to count all comments.'),
'source' => array(
'data' => 'nid',
),
'optional' => FALSE,
),
),
),
'countNew' => array(
'file' => array(
'type' => 'inc',
'module' => 'services',
'name' => 'resources/comment_resource',
),
'help' => t('This method returns the number of new comments on a given node since a given timestamp.'),
'access callback' => '_comment_resource_access',
'access arguments' => array(
'view',
),
'callback' => '_comment_resource_count_new',
'args' => array(
array(
'name' => 'nid',
'type' => 'int',
'description' => t('The node id to load comments for.'),
'source' => array(
'data' => 'nid',
),
'optional' => FALSE,
),
array(
'name' => 'since',
'type' => 'int',
'optional' => TRUE,
'description' => t('Timestamp to count from (defaults to time of last user acces to node).'),
'source' => array(
'data' => 'since',
),
'optional' => TRUE,
'default value' => 0,
),
),
),
),
),
);
}