You are here

function _taxonomy_resource_definition in Services 6.3

Same name and namespace in other branches
  1. 7.3 resources/taxonomy_resource.inc \_taxonomy_resource_definition()

@file Link general taxonomy functionalities to services module.

1 call to _taxonomy_resource_definition()
_services_core_resources in ./services.resource_build.inc
Supplies the resource definitions for Drupal core data

File

resources/taxonomy_resource.inc, line 7
Link general taxonomy functionalities to services module.

Code

function _taxonomy_resource_definition() {
  if (!module_exists('taxonomy')) {
    return array();
  }
  return array(
    'taxonomy_term' => array(
      'operations' => array(
        'retrieve' => array(
          'callback' => '_taxonomy_term_resource_retrieve',
          'args' => array(
            array(
              'name' => 'tid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'type' => 'int',
              'description' => 'The tid of the taxonomy term to get',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'view',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'create' => array(
          'callback' => '_taxonomy_term_resource_create',
          'args' => array(
            array(
              'name' => 'term',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy term array to create',
              'type' => 'array',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'create',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'update' => array(
          'callback' => '_taxonomy_term_resource_update',
          'args' => array(
            array(
              'name' => 'tid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'description' => 'The unique identifier for this taxonomy term.',
              'type' => 'int',
            ),
            array(
              'name' => 'term',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy term data to update',
              'type' => 'array',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'update',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'delete' => array(
          'callback' => '_taxonomy_term_resource_delete',
          'args' => array(
            array(
              'name' => 'tid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'delete',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'index' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'callback' => '_taxonomy_term_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_taxonomy_term_index_page_size', 20),
              'source' => array(
                'param' => 'pagesize',
              ),
            ),
          ),
          'access arguments' => array(
            'access content',
          ),
        ),
      ),
      'actions' => array(
        'selectNodes' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'help' => t('This method returns all nodes with provided taxonomy id.'),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'view',
          ),
          'access arguments append' => TRUE,
          'callback' => 'taxonomy_service_select_nodes',
          'args' => array(
            array(
              'name' => 'tids',
              'type' => 'string',
              'description' => t('The vocabulary ids to retrieve, separated by comma.'),
              'source' => array(
                'data' => 'tids',
              ),
              'optional' => FALSE,
            ),
            array(
              'name' => 'fields',
              'type' => 'string',
              'description' => t('The fields to retrieve, separated by comma.'),
              'source' => array(
                'data' => 'fields',
              ),
              'optional' => TRUE,
              'default value' => array(),
            ),
            array(
              'name' => 'operator',
              'type' => 'string',
              'description' => t('How to interpret multiple IDs in the array. Can be "or" or "and".'),
              'source' => array(
                'data' => 'operator',
              ),
              'optional' => TRUE,
              'default value' => 'or',
            ),
            array(
              'name' => 'depth',
              'type' => 'int',
              'description' => t('How many levels deep to traverse the taxonomy tree. Can be a nonnegative integer or "all".'),
              'source' => array(
                'data' => 'depth',
              ),
              'optional' => TRUE,
              'default value' => 0,
            ),
            array(
              'name' => 'pager',
              'type' => 'int',
              'description' => t('Whether the nodes are to be used with a pager (the case on most Drupal pages) or not (in an XML feed, for example).'),
              'source' => array(
                'data' => 'pager',
              ),
              'optional' => TRUE,
              'default value' => TRUE,
            ),
            array(
              'name' => 'order',
              'type' => 'string',
              'description' => t('The order clause for the query that retrieve the nodes.'),
              'source' => array(
                'data' => 'order',
              ),
              'optional' => TRUE,
              'default value' => 'n.sticky DESC, n.created DESC',
            ),
          ),
        ),
      ),
    ),
    'taxonomy_vocabulary' => array(
      'file' => array(
        'type' => 'inc',
        'module' => 'services',
        'name' => 'resources/taxonomy_resource',
      ),
      'operations' => array(
        'retrieve' => array(
          'callback' => '_taxonomy_vocabulary_resource_retrieve',
          'args' => array(
            array(
              'name' => 'vid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'type' => 'int',
              'description' => 'The vid of the taxonomy vocabulary to get',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'view',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'create' => array(
          'callback' => '_taxonomy_vocabulary_resource_create',
          'args' => array(
            array(
              'name' => 'vocabulary',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy vocabulary array to create',
              'type' => 'array',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'create',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'update' => array(
          'callback' => '_taxonomy_vocabulary_resource_update',
          'args' => array(
            array(
              'name' => 'vid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'description' => 'The unique identifier for this taxonomy vocabulary.',
              'type' => 'int',
            ),
            array(
              'name' => 'vocabulary',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy vocabulary data to update',
              'type' => 'array',
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'update',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'delete' => array(
          'callback' => '_taxonomy_vocabulary_resource_delete',
          'args' => array(
            array(
              'name' => 'vid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
            ),
          ),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'delete',
          ),
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'index' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'callback' => '_taxonomy_vocabulary_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_taxonomy_vocabulary_index_page_size', 20),
              'source' => array(
                'param' => 'pagesize',
              ),
            ),
          ),
          'access arguments' => array(
            'access content',
          ),
        ),
      ),
      'actions' => array(
        'getTree' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'help' => t('This method returns a full list of taxonomy terms.'),
          'access callback' => '_taxonomy_resource_access',
          'access arguments' => array(
            'view',
          ),
          'access arguments append' => TRUE,
          'callback' => 'taxonomy_service_get_tree',
          'args' => array(
            array(
              'name' => 'vid',
              'type' => 'int',
              'description' => t('The vocabulary id to retrieve.'),
              'source' => array(
                'data' => 'vid',
              ),
              'optional' => FALSE,
            ),
            array(
              'name' => 'parent',
              'type' => 'int',
              'description' => t('The term ID under which to generate the tree. If 0, generate the tree for the entire vocabulary.'),
              'source' => array(
                'data' => 'parent',
              ),
              'default value' => 0,
              'optional' => TRUE,
            ),
            array(
              'name' => 'maxdepth',
              'type' => 'int',
              'description' => t('The number of levels of the tree to return. Leave NULL to return all levels.'),
              'source' => array(
                'data' => 'maxdepth',
              ),
              'default value' => NULL,
              'optional' => TRUE,
            ),
          ),
        ),
      ),
    ),
  );
}