Skip to content

Commit

Permalink
REFACTOR LocationPage modeling (#223)
Browse files Browse the repository at this point in the history
Update the overall model pattern to be Page based.
  • Loading branch information
muskie9 authored Jul 21, 2020
1 parent 4e09b0a commit c54da72
Show file tree
Hide file tree
Showing 32 changed files with 1,125 additions and 193 deletions.
7 changes: 6 additions & 1 deletion _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ Dynamic\Locator\Location:
- Dynamic\SilverStripeGeocoder\AddressDataExtension
- SilverStripe\Versioned\Versioned('Stage','Live')

Dynamic\Locator\Locator:
Dynamic\Locator\Page\LocationPage:
extensions:
- Dynamic\SilverStripeGeocoder\DistanceDataExtension
- Dynamic\SilverStripeGeocoder\AddressDataExtension

Dynamic\Locator\Page\Locator:
infoWindowTemplate: 'dynamic/silverstripe-locator: client/infowindow-description.html'
listTemplate: 'dynamic/silverstripe-locator: client/location-list-description.html'
limit: 50
Expand Down
6 changes: 3 additions & 3 deletions _config/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name: locatorlegacy
---
SilverStripe\ORM\DatabaseAdmin:
classname_value_remapping:
Location: Dynamic\Locator\Location
Locator: Dynamic\Locator\Locator
LocationCategory: Dynamic\Locator\LocationCategory
Dynamic\Locator\Location: Dynamic\Locator\Location
Dynamic\Locator\Locator: Dynamic\Locator\Page\Locator
Dynamic\Locator\LocationCategory: Dynamic\Locator\Model\LocationCategory
144 changes: 74 additions & 70 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,74 +1,78 @@
{
"name": "dynamic/silverstripe-locator",
"description": "SilverStripe Locator Module. Show locations on a map. Search by geoposition.",
"keywords": [
"silverstripe",
"map",
"locator",
"dynamic",
"geocode",
"google maps",
"location"
],
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Dynamic",
"email": "[email protected]",
"homepage": "http://www.dynamicagency.com"
}
"name": "dynamic/silverstripe-locator",
"description": "SilverStripe Locator Module. Show locations on a map. Search by geoposition.",
"keywords": [
"silverstripe",
"map",
"locator",
"dynamic",
"geocode",
"google maps",
"location"
],
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Dynamic",
"email": "[email protected]",
"homepage": "http://www.dynamicagency.com"
}
],
"require": {
"colymba/gridfield-bulk-editing-tools": "^3.0",
"dynamic/silverstripe-geocoder": "^1.0",
"ext-dom": "*",
"ext-json": "*",
"littlegiant/silverstripe-catalogmanager": "^5.2",
"muskie9/data-to-arraylist": "^2.0",
"silverstripe/lumberjack": "^2.0",
"silverstripe/recipe-cms": "^4.0",
"silverstripe/vendor-plugin": "^1.0",
"symbiote/silverstripe-gridfieldextensions": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0",
"phpmd/phpmd": "^2.6",
"sebastian/phpcpd": "^3.0",
"phploc/phploc": "^4.0",
"pdepend/pdepend": "^2.5",
"theseer/phpdox": "^0.11.0"
},
"config": {
"process-timeout": 600
},
"autoload": {
"psr-4": {
"Dynamic\\Locator\\": "src/",
"Dynamic\\Locator\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"expose": [
"thirdparty",
"css",
"client"
],
"require": {
"silverstripe/recipe-cms": "^4.0",
"silverstripe/vendor-plugin": "^1.0",
"muskie9/data-to-arraylist": "^2.0",
"dynamic/silverstripe-geocoder": "^1.0",
"symbiote/silverstripe-gridfieldextensions": "^3.0",
"colymba/gridfield-bulk-editing-tools": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0",
"phpmd/phpmd": "^2.6",
"sebastian/phpcpd": "^3.0",
"phploc/phploc": "^4.0",
"pdepend/pdepend": "^2.5",
"theseer/phpdox": "^0.11.0"
"branch-alias": {
"dev-master": "4.x-dev"
},
"config": {
"process-timeout": 600
},
"autoload": {
"psr-4": {
"Dynamic\\Locator\\": "src/",
"Dynamic\\Locator\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"expose": [
"thirdparty",
"css",
"client"
],
"branch-alias": {
"dev-master": "4.x-dev"
},
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
}
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
}
}
2 changes: 1 addition & 1 deletion src/objects/Location.php → src/Model/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Dynamic\Locator;

use Dynamic\Locator\Model\LocationCategory;
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\Security\PermissionProvider;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Security\Permission;
use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton;

Expand Down
27 changes: 15 additions & 12 deletions src/objects/LocationCategory.php → src/Model/LocationCategory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace Dynamic\Locator;
namespace Dynamic\Locator\Model;

use Dynamic\Locator\Location;
use Dynamic\Locator\Page\Locator;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
Expand All @@ -15,8 +18,8 @@
* Class LocationCategory
*
* @property string $Name
* @method Locations|ManyManyList LocationSet()
* @method Locators|ManyManyList Locators()
* @method ManyManyList LocationSet()
* @method ManyManyList Locators()
*/
class LocationCategory extends DataObject
{
Expand All @@ -33,17 +36,17 @@ class LocationCategory extends DataObject
/**
* @var array
*/
private static $db = array(
private static $db = [
'Name' => 'Varchar(100)',
);
];

/**
* @var array
*/
private static $belongs_many_many = array(
private static $belongs_many_many = [
'Locators' => Locator::class,
'LocationSet' => Location::class,
);
];

/**
* @var string
Expand All @@ -60,7 +63,7 @@ class LocationCategory extends DataObject
*/
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function ($fields) {
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName([
'Locations',
'LocationSet',
Expand All @@ -74,17 +77,17 @@ public function getCMSFields()
$config = GridFieldConfig_RelationEditor::create();
$config->removeComponentsByType([
GridFieldAddExistingAutocompleter::class,
GridFieldAddNewButton::class
GridFieldAddNewButton::class,
])
->addComponents([
new GridFieldAddExistingSearchButton(),
]);
$locations = $this->Locations();
$locationField = GridField::create('Locations', 'Locations', $locations, $config);

$fields->addFieldsToTab('Root.Main', array(
$fields->addFieldsToTab('Root.Main', [
$locationField,
));
]);
}
});

Expand All @@ -95,7 +98,7 @@ public function getCMSFields()

/**
* For backwards compatability
* @return Locations|ManyManyList
* @return ManyManyList
*/
public function Locations()
{
Expand Down
Loading

0 comments on commit c54da72

Please sign in to comment.