diff --git a/geofield.info b/geofield.info index a39c5a7..ebf6e42 100644 --- a/geofield.info +++ b/geofield.info @@ -25,4 +25,4 @@ files[] = views/proximity_plugins/geofieldProximityEntityURL.inc files[] = views/proximity_plugins/geofieldProximityOtherGeofield.inc files[] = views/proximity_plugins/geofieldProximityCurrentUser.inc files[] = views/proximity_plugins/geofieldProximityExposedFilter.inc -files[] = views/proximity_plugins/geofieldProximityContextualFilter.inc \ No newline at end of file +files[] = views/proximity_plugins/geofieldProximityContextualFilter.inc diff --git a/geofield.migrate.inc b/geofield.migrate.inc index 9290515..75d7117 100644 --- a/geofield.migrate.inc +++ b/geofield.migrate.inc @@ -2,11 +2,10 @@ /** * @file - * Support for migration into Geofield fields + * Support for migration into Geofield fields. * * Based on addressfield.migrate.inc * in the Address Field module. - * */ /** @@ -17,8 +16,8 @@ function geofield_migrate_api() { 'api' => 2, 'field handlers' => array('MigrateGeofieldFieldHandler'), ); -} - +} + /** * Primary value passed to this field must be the Geometry type string. * @@ -28,7 +27,7 @@ function geofield_migrate_api() { * avoid having fields flagged as as unmapped: * @code * - * $this->addFieldMapping('field_geofield','foo'); + * $this->addFieldMapping('field_geofield', 'foo'); * $this->addFieldMapping('field_geofield:wkt', 'wkt'); * $this->addFieldMapping('field_geofield:lat', 'lat'); * $this->addFieldMapping('field_geofield:lon', 'lon'); @@ -36,6 +35,9 @@ function geofield_migrate_api() { */ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { + /** + * Registers the geofield field type. + */ public function __construct() { $this->registerTypes(array('geofield')); } @@ -43,14 +45,16 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { /** * Implementation of MigrateFieldHandler::fields(). * - * @param $type - * The field type. - * @param $instance - * Instance info for the field. - * @param Migration $migration - * The migration context for the parent field. We can look at the mappings - * and determine which subfields are relevant. + * @param string $type + * The field type. + * @param array $instance + * Instance info for the field. + * @param object $migration + * The migration context for the parent field. We can look at the mappings + * and determine which subfields are relevant. + * * @return array + * List of subfields. */ public function fields($type, $instance, $migration = NULL) { return array( @@ -70,12 +74,14 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { /** * Implements MigrateFieldHandler::prepare(). * - * @param $entity + * @param object $entity + * Entity which is going to embed the field. * @param array $field_info + * Info for the field. * @param array $instance + * Instance info for the field. * @param array $values - * - * @return null + * Values to be stored in the field. */ public function prepare($entity, array $field_info, array $instance, array $values) { $arguments = array(); @@ -86,7 +92,7 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { $language = $this->getFieldLanguage($entity, $field_info, $arguments); // Setup a Field API array for saving. - // Use https://drupal.org/node/1854188 as a guide for geoPHP field type + // Use https://drupal.org/node/1854188 as a guide for geoPHP field type. $delta = 0; foreach ($values as $value) { $input_format = $arguments['input_format']; @@ -94,21 +100,24 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { $return[$language][$delta]['input_format'] = $arguments['input_format']; switch ($input_format) { case 'wkt': - // wkt - Well known text - array of WKT data + // Well known text - array of WKT data. $return[$language][$delta]['geom'] = $value; break; + case 'json': - // json - GeoJSON - requires array of JSON data + // GeoJSON - requires array of JSON data. $return[$language][$delta]['geom'] = $value; break; + case 'lat/lon': - // lat/lon - Lat/Long - requires array of lat and lon source fields - $return[$language][$delta]['geom']['lat'] = $arguments['lat']; + // Lat/Long - requires array of lat and lon source fields. + $return[$language][$delta]['geom']['lat'] = $arguments['lat']; $return[$language][$delta]['geom']['lon'] = $arguments['lon']; break; + case 'bounds': - // bounds - delimited area marked by an array of - // left (lon), top (lat), right (long), bottom (lat) values + // Delimited area marked by an array of left (lon), top (lat), right + // (long), bottom (lat) values. $return[$language][$delta]['geom']['left'] = $arguments['left']; $return[$language][$delta]['geom']['top'] = $arguments['top']; $return[$language][$delta]['geom']['right'] = $arguments['right']; @@ -117,7 +126,7 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { } } else { - // if no input format specified the $value is assumed to represent a + // If no input format specified the $value is assumed to represent a // a WKT value or another format that can be parsed by geoPHP. $return[$language][$delta]['geom'] = $value; } @@ -130,11 +139,15 @@ class MigrateGeofieldFieldHandler extends MigrateFieldHandler { /** * Builds an array with additional data for the current $delta. * - * @param array $arguments - * @param array $field_info - * @param $delta + * @param array $arguments + * Arguments. + * @param array $field_info + * Info for the field. + * @param int $delta + * Order of value (typically for multi-valued fields). * * @return array + * Array with additional data. */ protected function prepareArguments(array $arguments, array $field_info, $delta) { $result = array();