You are here

node_resource.module in Services 7

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

File

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

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(
      '#file' => array(
        'file' => 'inc',
        'module' => 'node_resource',
      ),
      '#retrieve' => array(
        '#callback' => '_node_resource_retrieve',
        '#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',
        '#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',
        '#args' => array(
          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',
        '#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',
        '#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 ($op != 'create' && !empty($args)) {
    $node = node_load($args[0]);
  }
  return node_access($op, $node);
}