You are here

function _taxonomy_resource_definition in Services 7.3

Same name and namespace in other branches
  1. 6.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 includes/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(
          'help' => 'Retrieve a term',
          '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 arguments' => array(
            'access content',
          ),
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'create' => array(
          'help' => 'Create a term',
          'callback' => '_taxonomy_term_resource_create',
          'args' => array(
            array(
              'name' => 'term',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy term object to create',
              'type' => 'array',
            ),
          ),
          'access callback' => '_taxonomy_resource_create_access',
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'update' => array(
          'help' => 'Update a term',
          '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_update_access',
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'delete' => array(
          'help' => 'Delete the term',
          'callback' => '_taxonomy_term_resource_delete',
          'args' => array(
            array(
              'name' => 'tid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'type' => 'int',
            ),
          ),
          'access callback' => '_taxonomy_resource_delete_access',
          'access arguments append' => TRUE,
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'index' => array(
          'help' => 'List all terms',
          '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',
              ),
            ),
            array(
              'name' => 'options',
              'optional' => TRUE,
              'type' => 'array',
              'description' => 'Additional query options.',
              'default value' => array(
                'orderby' => array(
                  'vid' => 'DESC',
                  'weight' => 'DESC',
                  'name' => 'DESC',
                ),
              ),
              'source' => array(
                'param' => 'options',
              ),
            ),
          ),
          'access arguments' => array(
            'access content',
          ),
        ),
      ),
      'actions' => array(
        'selectNodes' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'help' => t('Returns all nodes with provided taxonomy id.'),
          'access arguments' => array(
            'access content',
          ),
          'callback' => 'taxonomy_service_select_nodes',
          'args' => array(
            array(
              'name' => 'tid',
              'type' => 'string',
              'description' => t('The vocabulary ids to retrieve, separated by comma.'),
              'source' => array(
                'data' => 'tid',
              ),
              'optional' => FALSE,
            ),
            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' => 'limit',
              'type' => 'int',
              'description' => t('Maximum number of nodes to find.'),
              'source' => array(
                'data' => 'limit',
              ),
              'optional' => TRUE,
              'default value' => FALSE,
            ),
            array(
              'name' => 'order',
              'type' => 'int',
              'description' => t('The order clause for the query that retrieve the nodes.'),
              'source' => array(
                'data' => 'order',
              ),
              'optional' => TRUE,
              'default value' => array(
                't.sticky' => 'DESC',
                't.created' => 'DESC',
              ),
            ),
          ),
        ),
      ),
    ),
    'taxonomy_vocabulary' => array(
      'file' => array(
        'type' => 'inc',
        'module' => 'services',
        'name' => 'resources/taxonomy_resource',
      ),
      'operations' => array(
        'retrieve' => array(
          'help' => 'Retrieve a taxonomy vocabulary',
          '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 arguments' => array(
            'access content',
          ),
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'create' => array(
          'help' => 'Create a taxonomy vocabulary',
          'callback' => '_taxonomy_vocabulary_resource_create',
          'args' => array(
            array(
              'name' => 'vocabulary',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'The taxonomy vocabulary object to create',
              'type' => 'array',
            ),
          ),
          'access arguments' => array(
            'administer taxonomy',
          ),
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'update' => array(
          'help' => 'Update a taxonomy vocabulary',
          '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 arguments' => array(
            'administer taxonomy',
          ),
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'delete' => array(
          'help' => 'Delete a taxonomy vocabulary',
          'callback' => '_taxonomy_vocabulary_resource_delete',
          'args' => array(
            array(
              'name' => 'vid',
              'optional' => FALSE,
              'source' => array(
                'path' => 0,
              ),
              'type' => 'int',
            ),
          ),
          'access arguments' => array(
            'administer taxonomy',
          ),
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
        ),
        'index' => array(
          'help' => 'List all taxonomy vocabularies',
          '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',
              ),
            ),
            array(
              'name' => 'options',
              'optional' => TRUE,
              'type' => 'array',
              'description' => 'Additional query options.',
              'default value' => array(
                'orderby' => array(
                  'weight' => 'DESC',
                  'name' => 'DESC',
                ),
              ),
              'source' => array(
                'param' => 'options',
              ),
            ),
          ),
          'access arguments' => array(
            'access content',
          ),
        ),
      ),
      'actions' => array(
        'retrieveByMachineName' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'help' => t('Returns a vocabulary based on machine name.'),
          'access arguments' => array(
            'access content',
          ),
          'callback' => 'taxonomy_service_get_by_machine_name',
          'args' => array(
            array(
              'name' => 'machine_name',
              'type' => 'string',
              'description' => t('The vocabulary id to retrieve.'),
              'source' => array(
                'data' => 'machine_name',
              ),
              'optional' => FALSE,
            ),
          ),
        ),
        'getTree' => array(
          'file' => array(
            'type' => 'inc',
            'module' => 'services',
            'name' => 'resources/taxonomy_resource',
          ),
          'help' => t('Returns a full list of taxonomy terms.'),
          'access arguments' => array(
            'access content',
          ),
          '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,
            ),
            array(
              'name' => 'load_entities',
              'type' => 'int',
              'description' => t('Whether the tree of terms should contain full term entity objects. If 1 (TRUE), a full entity load will occur on the term objects. Otherwise they are partial objects to save execution time and memory consumption. Defaults to 0 (FALSE).'),
              'source' => array(
                'data' => 'load_entities',
              ),
              'default value' => 0,
              'optional' => TRUE,
            ),
          ),
        ),
      ),
    ),
  );
}