@@ -25,11 +25,9 @@ discard block |
||
| 25 | 25 | public static function getEcId($ec) { |
| 26 | 26 | if (isset($ec->field_esd_ec_id['und']) && isset($ec->field_esd_ec_id['und'][0]) && isset($ec->field_esd_ec_id['und'][0]['value'])) { |
| 27 | 27 | return $ec->field_esd_ec_id['und'][0]['value']; |
| 28 | - } |
|
| 29 | - elseif (gettype($ec->field_esd_ec_id) == 'string') { |
|
| 28 | + } elseif (gettype($ec->field_esd_ec_id) == 'string') { |
|
| 30 | 29 | return $ec->field_esd_ec_id; |
| 31 | - } |
|
| 32 | - else { |
|
| 30 | + } else { |
|
| 33 | 31 | return NULL; |
| 34 | 32 | } |
| 35 | 33 | } |
@@ -132,8 +130,7 @@ discard block |
||
| 132 | 130 | $cloned_entity->{$url_field_name} = $url; |
| 133 | 131 | } |
| 134 | 132 | } |
| 135 | - } |
|
| 136 | - else { |
|
| 133 | + } else { |
|
| 137 | 134 | // Otherwise loop over the field and generate each URL. |
| 138 | 135 | $cloned_entity->{$url_field_name} = array(); |
| 139 | 136 | foreach ($clone_wrapper->{$field_name}->getIterator() as $delta => $field_wrapper) { |
@@ -170,15 +167,13 @@ discard block |
||
| 170 | 167 | if ($cloned_entity->{$field_name}) { |
| 171 | 168 | $cloned_entity->{$field_name} = ['tid' => $term->tid, 'name' => $term->name]; |
| 172 | 169 | } |
| 173 | - } |
|
| 174 | - elseif ($clone_wrapper->{$field_name}->type() == 'list<taxonomy_term>') { |
|
| 170 | + } elseif ($clone_wrapper->{$field_name}->type() == 'list<taxonomy_term>') { |
|
| 175 | 171 | $new_val = []; |
| 176 | 172 | foreach ($clone_wrapper->{$field_name}->value() as $term) { |
| 177 | 173 | $new_val[] = ['tid' => $term->tid, 'name' => $term->name]; |
| 178 | 174 | } |
| 179 | 175 | $cloned_entity->{$field_name} = $new_val; |
| 180 | - } |
|
| 181 | - elseif ($clone_wrapper->{$field_name}->type() == 'list<text>') { |
|
| 176 | + } elseif ($clone_wrapper->{$field_name}->type() == 'list<text>') { |
|
| 182 | 177 | $opts = $clone_wrapper->{$field_name}->optionsList(); |
| 183 | 178 | $newval = []; |
| 184 | 179 | $iter = 0; |
@@ -195,14 +190,12 @@ discard block |
||
| 195 | 190 | |
| 196 | 191 | $cloned_entity->{$field_name} = $newval; |
| 197 | 192 | unset($newval); |
| 198 | - } |
|
| 199 | - elseif ($clone_wrapper->{$field_name}->type() == 'text' && $clone_wrapper->{$field_name}->label()) { |
|
| 193 | + } elseif ($clone_wrapper->{$field_name}->type() == 'text' && $clone_wrapper->{$field_name}->label()) { |
|
| 200 | 194 | $cloned_entity->{$field_name} = [ |
| 201 | 195 | 'machine_name' => $clone_wrapper->{$field_name}->value(), |
| 202 | 196 | 'label' => $clone_wrapper->{$field_name}->label(), |
| 203 | 197 | ]; |
| 204 | - } |
|
| 205 | - else { |
|
| 198 | + } else { |
|
| 206 | 199 | $cloned_entity->{$field_name} = $clone_wrapper->{$field_name}->raw(); |
| 207 | 200 | } |
| 208 | 201 | } |
@@ -304,8 +297,7 @@ discard block |
||
| 304 | 297 | // If a specific bundle's fields was requested, return just those. |
| 305 | 298 | if (!empty($bundle)) { |
| 306 | 299 | return $fields[$entity_type][$bundle]; |
| 307 | - } |
|
| 308 | - else { |
|
| 300 | + } else { |
|
| 309 | 301 | // Otherwise combine all the fields for various bundles of the entity type |
| 310 | 302 | // into a single return value. |
| 311 | 303 | $combined_fields = array(); |
@@ -359,8 +351,7 @@ discard block |
||
| 359 | 351 | |
| 360 | 352 | if (in_array($filter_field, array_keys($properties), TRUE)) { |
| 361 | 353 | $query->propertyCondition($properties[$filter_field], $filter_value, $operator); |
| 362 | - } |
|
| 363 | - else { |
|
| 354 | + } else { |
|
| 364 | 355 | // Look for the field name among the entity type's field list. |
| 365 | 356 | foreach (self::entityTypeFields($entity_type) as $field_name => $field_type) { |
| 366 | 357 | // If the filter field begins with a field name, then either the |
@@ -384,8 +375,7 @@ discard block |
||
| 384 | 375 | $column = key($field_info['columns']); |
| 385 | 376 | $query->fieldCondition($field_name, $column, $filter_value, $operator); |
| 386 | 377 | break; |
| 387 | - } |
|
| 388 | - else { |
|
| 378 | + } else { |
|
| 389 | 379 | // Otherwise if the filter field contains a valid column |
| 390 | 380 | // specification for the field type, add the field condition to |
| 391 | 381 | // the index query. |
@@ -438,8 +428,7 @@ discard block |
||
| 438 | 428 | |
| 439 | 429 | if (in_array($sort_field, array_keys($properties), TRUE)) { |
| 440 | 430 | $query->propertyOrderBy($properties[$sort_field], $direction); |
| 441 | - } |
|
| 442 | - else { |
|
| 431 | + } else { |
|
| 443 | 432 | // Look for the field name among the entity type's field list. |
| 444 | 433 | foreach (self::entityTypeFields($entity_type) as $field_name => $field_type) { |
| 445 | 434 | // If the sort field begins with a field name, then either the sort |
@@ -453,8 +442,7 @@ discard block |
||
| 453 | 442 | $column = key($field_info['columns']); |
| 454 | 443 | $query->fieldOrderBy($field_name, $column, $direction); |
| 455 | 444 | break; |
| 456 | - } |
|
| 457 | - else { |
|
| 445 | + } else { |
|
| 458 | 446 | // Otherwise if the sort field contains a valid column |
| 459 | 447 | // specification for the field type, add the field condition to |
| 460 | 448 | // the index query. |
@@ -583,8 +583,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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. |