You are here

node_resource.module in Services 6.2

Same filename and directory in other branches
  1. 7 services/node_service/node_resource.module

CRUD resource functionality for nodes.

File

services/node_service/node_resource.module
View source
<?php

/**
 * @file
 *  CRUD resource functionality for nodes.
 */
function node_resource_autoload_info() {
  return array(
    'NodeResourceFeedModel' => array(
      'file' => 'node_resource.models.inc',
    ),
    'NodeResourceViewFeedModel' => array(
      'file' => 'node_resource.models.inc',
    ),
  );
}
function node_resource_service_resource() {
  return array(
    'node' => array(
      '#retrieve' => array(
        '#callback' => '_node_resource_retrieve',
        '#file' => array(
          'file' => 'inc',
          'module' => 'node_resource',
        ),
        '#args' => array(
          array(
            '#name' => 'nid',
            '#optional' => FALSE,
            '#source' => array(
              'path' => 0,
            ),
            '#type' => 'int',
            '#description' => 'The nid of the node to get',
          ),
        ),
        '#models' => array(
          'ResourceFeedModel' => array(
            'class' => 'NodeResourceFeedModel',
            'arguments' => array(
              'source' => 'single',
            ),
          ),
        ),
        '#access callback' => '_node_resource_access',
        '#access arguments' => array(
          'view',
        ),
        '#access arguments append' => TRUE,
      ),
      '#create' => array(
        '#callback' => '_node_resource_create',
        '#file' => array(
          'file' => 'inc',
          'module' => 'node_resource',
        ),
        '#args' => array(
          array(
            '#name' => 'node',
            '#optional' => FALSE,
            '#source' => 'data',
            '#description' => 'The node object to create',
            '#type' => 'struct',
          ),
        ),
        '#access callback' => '_node_resource_access',
        '#access arguments' => array(
          'create',
        ),
        '#access arguments append' => TRUE,
      ),
      '#update' => array(
        '#callback' => '_node_resource_update',
        '#file' => array(
          'file' => 'inc',
          'module' => 'node_resource',
        ),
        '#args' => array(
          array(
            '#name' => 'nid',
            '#optional' => FALSE,
            '#source' => array(
              'path' => 0,
            ),
            '#type' => 'int',
            '#description' => 'The nid of the node to get',
          ),
          array(
            '#name' => 'node',
            '#optional' => FALSE,
            '#source' => 'data',
            '#description' => 'The node data to update',
            '#type' => 'struct',
          ),
        ),
        '#access callback' => '_node_resource_access',
        '#access arguments' => array(
          'update',
        ),
        '#access arguments append' => TRUE,
      ),
      '#delete' => array(
        '#callback' => '_node_resource_delete',
        '#file' => array(
          'file' => 'inc',
          'module' => 'node_resource',
        ),
        '#args' => array(
          array(
            '#name' => 'nid',
            '#optional' => FALSE,
            '#source' => array(
              'path' => 0,
            ),
          ),
        ),
        '#access callback' => '_node_resource_access',
        '#access arguments' => array(
          'delete',
        ),
        '#access arguments append' => TRUE,
      ),
      '#index' => array(
        '#callback' => '_node_resource_index',
        '#file' => array(
          'file' => 'inc',
          'module' => 'node_resource',
        ),
        '#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' => 'struct',
            '#description' => 'Parameters',
            '#default value' => NULL,
            '#source' => 'param',
          ),
        ),
        '#models' => array(
          'ResourceFeedModel' => array(
            'class' => 'NodeResourceFeedModel',
          ),
          'ResourceTimeFeedModel' => array(
            'class' => 'NodeResourceFeedModel',
          ),
        ),
        '#access arguments' => array(
          'access content',
        ),
        '#access arguments append' => TRUE,
      ),
    ),
  );
}
function _node_resource_access($op = 'view', $args = array()) {
  if (!empty($args)) {
    $node = $op == 'create' ? $args[0] : node_load($args[0]);
  }
  return node_access($op, $node);
}

Functions

Namesort descending Description
node_resource_autoload_info @file CRUD resource functionality for nodes.
node_resource_service_resource
_node_resource_access