Skip to content

Commit

Permalink
SilverStripe alpha7 updates
Browse files Browse the repository at this point in the history
use dynamic/silverstripe-geocoder for geocoding
  • Loading branch information
jsirish committed May 16, 2017
1 parent b300f9d commit 8ebfdc7
Show file tree
Hide file tree
Showing 22 changed files with 457 additions and 373 deletions.
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ env:

matrix:
include:
- php: 5.6
env: DB=PGSQL
- php: 5.6
- php: 7.0
env: DB=SQLITE
- php: 5.6
env: COVERAGE=1
- php: 7.0
env: DB=PGSQL
- php: 7.0
env: COVERAGE=1
- php: 5.6


before_script:
Expand All @@ -34,16 +34,18 @@ before_script:
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss
- mv "$MODULE_PATH/phpunit.xml.dist" .

#Execute tests with or without coverage
script:
# Execute tests with no coverage. This is the fastest option
- "if [ \"$COVERAGE\" = \"0\" ]; then vendor/bin/phpunit $MODULE_PATH/tests/; fi"

# Execute tests with coverage. Do this for a small
- "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.clover $MODULE_PATH/tests/; fi"

after_script:
# Upload code coverage when tests pass
after_success:
- "if [ \"$COVERAGE\" = \"1\" ]; then mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/; fi"
- cd ~/build/$TRAVIS_REPO_SLUG
- wget https://scrutinizer-ci.com/ocular.phar
- "if [ \"$COVERAGE\" = \"1\" ]; then travis_retry codecov && travis_retry php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi"
7 changes: 3 additions & 4 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
Name: locator
---
Location:
Dynamic\Locator\Location:
extensions:
- Addressable
- Geocodable
- DistanceDataExtension
- Dynamic\Locator\DistanceDataExtension
- SilverStripe\Versioned\Versioned('Stage','Live')
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
"require": {
"silverstripe/framework": "^4.0",
"silverstripe/cms": "^4.0",
"muskie9/data-to-arraylist": "^2.0"
"muskie9/data-to-arraylist": "^2.0",
"dynamic/silverstripe-geocoder": "^1.0"
},
"suggest": {
"silverstripe-australia/addressable": "^1.1",
"unclecheese/betterbuttons": "Adds new form actions and buttons to GridField detail form for usability enhancements.",
"unclecheese/bootstrap-forms": "Allows the creation of forms compatible with the Twitter Bootstrap CSS framework in SilverStripe."
},
"autoload": {
"psr-4": {
"Dynamic\\Locator\\": "src/",
"Dynamic\\Locator\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"installer-name": "locator",
"branch-alias": {
Expand Down
21 changes: 0 additions & 21 deletions phpunit.xml

This file was deleted.

14 changes: 14 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<phpunit bootstrap="framework/tests/bootstrap.php" colors="true">
<testsuite name="locator">
<directory>locator/tests</directory>
</testsuite>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">locator/src/</directory>
<exclude>
<directory suffix=".php">locator/tests/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Dynamic\Locator;

use SilverStripe\ORM\DataExtension,
SilverStripe\ORM\Queries\SQLSelect,
SilverStripe\ORM\DataQuery,
SilverStripe\Control\Controller;
use Dynamic\SilverStripeGeocoder\GoogleGeocoder;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\ORM\DataQuery;
use SilverStripe\Control\Controller;

class DistanceDataExtension extends DataExtension
{
Expand All @@ -19,12 +20,12 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
if ($this->owner->hasMethod('updateAddressValue')) {
$address = $this->owner->updateAddressValue($address);
}
if (class_exists('GoogleGeocoding')) {
if (class_exists(GoogleGeocoder::class)) {
if ($address) { // on frontend
$coords = GoogleGeocoding::address_to_point($address);

$Lat = $coords['lat'];
$Lng = $coords['lng'];
$geocoder = new GoogleGeocoder($address);
$response = $geocoder->getResult();
$Lat = $response->getLatitude();
$Lng = $response->getLongitude();

$query
->addSelect(array(
Expand Down
23 changes: 12 additions & 11 deletions code/form/LocatorForm.php → src/form/LocatorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Dynamic\Locator;

use SilverStripe\Forms\Form,
SilverStripe\Forms\FieldList,
SilverStripe\Forms\TextField,
SilverStripe\Forms\DropdownField,
SilverStripe\Forms\FormAction,
SilverStripe\Forms\RequiredFields,
SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\Debug;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Control\Controller;

/**
* Class LocatorForm
Expand Down Expand Up @@ -59,8 +61,8 @@ public function __construct(Controller $controller, $name)
$fields->push($categoriesField);
}

if (Config::inst()->get('LocatorForm', 'show_radius')) {
$radiusArray = Config::inst()->get('LocatorForm', 'radius_array');
if (Config::inst()->get(LocatorForm::class, 'show_radius')) {
$radiusArray = Config::inst()->get(LocatorForm::class, 'radius_array');
$this->extend('overrideRadiusArray', $radiusArray);
$fields->push(DropdownField::create('Radius', '', $radiusArray)
->setEmptyString('radius')
Expand All @@ -78,7 +80,7 @@ public function __construct(Controller $controller, $name)
}

/**
* @return Validator
* @return null|RequiredFields|\SilverStripe\Forms\Validator
*/
public function getValidator()
{
Expand All @@ -90,5 +92,4 @@ public function getValidator()
$this->extend('updateRequiredFields', $validator);
return $validator;
}

}
Loading

0 comments on commit 8ebfdc7

Please sign in to comment.