From 305d15b892ecbbec612ed12d8183d9958bd548e0 Mon Sep 17 00:00:00 2001
From: Chris Oden <wodenx@gmail.com>
Date: Sat, 5 Oct 2013 09:41:16 -0400
Subject: [PATCH] Patch 1: Add verbs for actions and relationships.

---
 services_documentation.admin.inc | 24 ++++++++++++++++++++++++
 services_documentation.inc       | 14 ++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/services_documentation.admin.inc b/services_documentation.admin.inc
index a30789e..ed1f794 100644
--- a/services_documentation.admin.inc
+++ b/services_documentation.admin.inc
@@ -108,6 +108,30 @@ function services_documentation_configure() {
     '#description' => t('Select verbs used to describe operations.'),
   );
 
+  // Designate custom actions verb.
+  $form['services_documentation_verbs_custom']['actions'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Custom Action Verb'),
+    '#default_value' => variable_get('services_documentation_verbs_custom_action', t('action')),
+    '#description' => t('Select verbs used to describe actions.'),
+  );
+
+  // Designate custom targeted actions verb.
+  $form['services_documentation_verbs_custom']['targeted_actions'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Custom Targeted Action Verb'),
+    '#default_value' => variable_get('services_documentation_verbs_custom_targeted_actions', t('targeted action')),
+    '#description' => t('Select verbs used to describe targeted action.'),
+  );
+
+  // Designate custom relationships verb.
+  $form['services_documentation_verbs_custom']['relationships'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Custom Relationship Verb'),
+    '#default_value' => variable_get('services_documentation_verbs_custom_relationships', t('relationships')),
+    '#description' => t('Select verbs used to describe relationships.'),
+  );
+
   // Use custom submit handler, rather than system_settings_form.
   $form['actions']['#type'] = 'actions';
   $form['actions']['submit'] = array(
diff --git a/services_documentation.inc b/services_documentation.inc
index 1c2c871..3fbd84c 100644
--- a/services_documentation.inc
+++ b/services_documentation.inc
@@ -90,6 +90,11 @@ function services_documentation_method_element($method) {
     if (!empty($verbs[$method['name']])) {
       $element['#verb'] = $verbs[$method['name']];
     }
+    elseif (!empty($verbs[$method['bundle']])) {
+      // If there is no verb for the method, see if there's one for the bundle.
+      // This allows customized verbs for "actions", "relationships", etc.
+      $element['#verb'] = $verbs[$method['bundle']];
+    }
   }
 
   $element['#title'] = $element['#verb'] . ' ' . $element['#path'];
@@ -188,6 +193,9 @@ function services_documentation_verbs($style) {
         'update' => 'update',
         'delete' => 'delete',
         'index' => 'index',
+        'actions' => 'action',
+        'targeted_actions' => 'targeted action',
+        'relationships' => 'relationship',
       );
       break;
 
@@ -198,6 +206,9 @@ function services_documentation_verbs($style) {
         'update' => 'PUT',
         'delete' => 'DELETE',
         'index' => 'GET',
+        'actions' => 'POST',
+        'targeted_actions' => 'POST',
+        'relationships' => 'GET',
       );
       break;
 
@@ -208,6 +219,9 @@ function services_documentation_verbs($style) {
         'update' => 'UPDATE',
         'delete' => 'DELETE',
         'index' => 'READ',
+        'actions' => 'ACTION',
+        'targeted_actions' => 'ACTION',
+        'relationships' => 'READ',
       );
       break;
 
-- 
1.8.1.3

