Completed
Push — 7.x-1.x ( 94de83...f8d1c3 )
by Benjamin
02:21
created
esdportal_api.module 1 patch
Braces   +17 added lines, -34 removed lines patch added patch discarded remove patch
@@ -583,8 +583,7 @@  discard block
 block discarded – undo
583 583
 function _esdportal_api_retrieve_ec_state_rating($esd_ec_id, $batch_timestamp = NULL) {
584 584
   if (isset($batch_timestamp) && $batch_timestamp > 0) {
585 585
     $rating = db_query('SELECT * FROM {ec_state_ratings} WHERE timestamp=:batch_timestamp AND esd_ec_id=:esd_ec_id', array(':esd_ec_id' => $esd_ec_id, ':batch_timestamp' => $batch_timestamp))->fetchAssoc();
586
-  }
587
-  else {
586
+  } else {
588 587
     $rating = db_query('SELECT * FROM {ec_state_ratings} WHERE timestamp=(SELECT MAX(timestamp) FROM {ec_state_ratings}) AND esd_ec_id=:esd_ec_id', array(':esd_ec_id' => $esd_ec_id))->fetchAssoc();
589 588
   }
590 589
   return $rating;
@@ -615,8 +614,7 @@  discard block
 block discarded – undo
615 614
 function _esdportal_api_index_ec_state_ratings($batch_timestamp = NULL) {
616 615
   if (isset($batch_timestamp) && $batch_timestamp > 0) {
617 616
     $ratings = db_query('SELECT * FROM {ec_state_ratings} WHERE timestamp=:batch_timestamp', array(':batch_timestamp' => $batch_timestamp))->fetchAssoc();
618
-  }
619
-  else {
617
+  } else {
620 618
     $ratings = db_query('SELECT * FROM {ec_state_ratings} WHERE timestamp=(SELECT MAX(timestamp) FROM {ec_state_ratings})')->fetchAll();
621 619
   }
622 620
 
@@ -794,16 +792,14 @@  discard block
 block discarded – undo
794 792
     // Some schools don't have BCODEs.
795 793
     if (!isset($school->field_bcode[LANGUAGE_NONE])) {
796 794
       $school->bcode = NULL;
797
-    }
798
-    else {
795
+    } else {
799 796
       $school->bcode = $school->field_bcode[LANGUAGE_NONE][0]['value'];
800 797
     }
801 798
 
802 799
     // Some schools don't have ESD internal school IDs.
803 800
     if (!isset($school->field_esd_schid[LANGUAGE_NONE])) {
804 801
       $school->esd_schid = NULL;
805
-    }
806
-    else {
802
+    } else {
807 803
       $school->esd_schid = $school->field_esd_schid[LANGUAGE_NONE][0]['value'];
808 804
     }
809 805
 
@@ -843,13 +839,11 @@  discard block
 block discarded – undo
843 839
 
844 840
           try {
845 841
             $res = $q->execute();
846
-          }
847
-          catch (Exception $e) {
842
+          } catch (Exception $e) {
848 843
             // No table?
849 844
             if ($e->getCode() == '42') {
850 845
               // Do nothing for now...
851
-            }
852
-            else {
846
+            } else {
853 847
               watchdog_exception('_esdportal_api_load_includes_for_schools', $e);
854 848
             }
855 849
           }
@@ -877,13 +871,11 @@  discard block
 block discarded – undo
877 871
 
878 872
           try {
879 873
             $res = $q->execute();
880
-          }
881
-          catch (Exception $e) {
874
+          } catch (Exception $e) {
882 875
             // No table?
883 876
             if ($e->getCode() == '42') {
884 877
               // Do nothing for now...
885
-            }
886
-            else {
878
+            } else {
887 879
               watchdog_exception('_esdportal_api_load_includes_for_schools', $e);
888 880
             }
889 881
           }
@@ -919,8 +911,7 @@  discard block
 block discarded – undo
919 911
     // Some ecs don't have program_ids.
920 912
     if (!isset($ec->field_esd_ec_id[LANGUAGE_NONE])) {
921 913
       $ec->program_id = NULL;
922
-    }
923
-    else {
914
+    } else {
924 915
       $ec->program_id = $ec->field_esd_ec_id[LANGUAGE_NONE][0]['value'];
925 916
     }
926 917
 
@@ -966,13 +957,11 @@  discard block
 block discarded – undo
966 957
 
967 958
           try {
968 959
             $res = $q->execute();
969
-          }
970
-          catch (Exception $e) {
960
+          } catch (Exception $e) {
971 961
             // No table?
972 962
             if ($e->getCode() == '42') {
973 963
               // Do nothing for now...
974
-            }
975
-            else {
964
+            } else {
976 965
               watchdog_exception('_esdportal_api_load_includes_for_schools', $e);
977 966
             }
978 967
           }
@@ -1136,16 +1125,14 @@  discard block
 block discarded – undo
1136 1125
   // Execute the query and load the terms it returns, if any.
1137 1126
   try {
1138 1127
     $result = $query->execute();
1139
-  }
1140
-  catch (Exception $e) {
1128
+  } catch (Exception $e) {
1141 1129
     return services_error(t('request error'), 400);
1142 1130
   }
1143 1131
 
1144 1132
   if (!empty($result['taxonomy_term'])) {
1145 1133
     $tids = array_keys($result['taxonomy_term']);
1146 1134
     $terms = taxonomy_term_load_multiple($tids);
1147
-  }
1148
-  else {
1135
+  } else {
1149 1136
     // Empty set.
1150 1137
     $terms = [];
1151 1138
   }
@@ -1240,14 +1227,12 @@  discard block
 block discarded – undo
1240 1227
       if (!empty($args[$key])) {
1241 1228
         if (is_string($args[$key])) {
1242 1229
           $args[$key] = explode($value['commerce_services_explode'], $args[$key]);
1243
-        }
1244
-        elseif (is_array($args[$key])) {
1230
+        } elseif (is_array($args[$key])) {
1245 1231
           foreach ($args[$key] as &$param) {
1246 1232
             $param = explode($value['commerce_services_explode'], $param);
1247 1233
           }
1248 1234
         }
1249
-      }
1250
-      else {
1235
+      } else {
1251 1236
         // Otherwise ensure it is just converted to an array.
1252 1237
         $args[$key] = array();
1253 1238
       }
@@ -1278,8 +1263,7 @@  discard block
 block discarded – undo
1278 1263
         // add it to the argument's value array now.
1279 1264
         if (in_array($param_key, array_keys(\Drupal\esdportal_api\EcDataUtils::entityTypeProperties($value['commerce_services_field_populate'])), TRUE)) {
1280 1265
           $args[$key][$param_key] = $param_value;
1281
-        }
1282
-        else {
1266
+        } else {
1283 1267
           // Otherwise look and see if the parameter key begins with a field
1284 1268
           // name, assuming it must be either a field name or field column name.
1285 1269
           foreach (array_keys(\Drupal\esdportal_api\EcDataUtils::entityTypeFields($value['commerce_services_field_populate'])) as $field_name) {
@@ -1291,8 +1275,7 @@  discard block
 block discarded – undo
1291 1275
               if ($field_name == $param_key && count($field_info['columns']) == 1) {
1292 1276
                 $args[$key][$param_key] = $param_value;
1293 1277
                 break;
1294
-              }
1295
-              else {
1278
+              } else {
1296 1279
                 // Otherwise if the parameter key contains a valid column
1297 1280
                 // specification for the field type, add it to the argument's
1298 1281
                 // value array as well.
Please login to merge, or discard this patch.