@@ -210,6 +210,7 @@ |
||
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Converts underscore_name to camelName. |
213 | + * @param string $underscore_name |
|
213 | 214 | */ |
214 | 215 | public static function underscoreToCamel($underscore_name) { |
215 | 216 | $underscore_name[0] = strtoupper($underscore_name[0]); |
@@ -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. |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @file |
|
4 | - * Useful helpers for the esdportal_api module. |
|
5 | - * |
|
6 | - * Contains: |
|
7 | - * Drupal\esdportal_api\EcDataUtils. |
|
8 | - */ |
|
3 | + * @file |
|
4 | + * Useful helpers for the esdportal_api module. |
|
5 | + * |
|
6 | + * Contains: |
|
7 | + * Drupal\esdportal_api\EcDataUtils. |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | namespace Drupal\esdportal_api; |
11 | 11 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Handles inclusion of ec_profiles. |
63 | 63 | */ |
64 | 64 | protected function ec_profile() { |
65 | - return function ($ec, $include, $included) { |
|
65 | + return function($ec, $include, $included) { |
|
66 | 66 | $serializer = new EcProfileSerializer($included); |
67 | 67 | |
68 | 68 | if (!$ec->ec_profile_id) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * Handles inclusion of most_recent_ec_state_ratings. |
82 | 82 | */ |
83 | 83 | protected function most_recent_ec_state_rating() { |
84 | - return function ($ec, $include, $included) { |
|
84 | + return function($ec, $include, $included) { |
|
85 | 85 | $serializer = new EcStateRatingSerializer($included); |
86 | 86 | |
87 | 87 | if (!isset($ec->most_recent_ec_state_rating)) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | self::$potentialDataTables = \Drupal\esdportal_api\EcDataUtils::getDataTablesWithProgramIds(); |
107 | 107 | self::$potentialDataTableNames = \Drupal\esdportal_api\EcDataUtils::extractDataTableNames(self::$potentialDataTables); |
108 | 108 | |
109 | - return function ($ec, $include, $included) use ($method) { |
|
109 | + return function($ec, $include, $included) use ($method) { |
|
110 | 110 | // The actual called method is underscore-separated... |
111 | 111 | $table_name = $method; |
112 | 112 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * Handles inclusion of school_profiles. |
85 | 85 | */ |
86 | 86 | protected function school_profile() { |
87 | - return function ($school, $include, $included) { |
|
87 | + return function($school, $include, $included) { |
|
88 | 88 | $serializer = new SchoolProfileSerializer($included); |
89 | 89 | |
90 | 90 | if (!$school->school_profile_id) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | self::$potentialDataTables = \Drupal\esdportal_api\EcDataUtils::getDataTablesWithBcodes(); |
110 | 110 | self::$potentialDataTableNames = \Drupal\esdportal_api\EcDataUtils::extractDataTableNames(self::$potentialDataTables); |
111 | 111 | |
112 | - return function ($school, $include, $included) use ($method) { |
|
112 | + return function($school, $include, $included) use ($method) { |
|
113 | 113 | // The actual called method is underscore-separated... |
114 | 114 | $table_name = $method; |
115 | 115 |