Skip to content

Commit 781ed0f

Browse files
committed
Move instantiation into constructor since stateless.
1 parent f12be13 commit 781ed0f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Model/Behavior/GeocoderBehavior.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function __construct(Table $table, array $config = []) {
106106
$this->_config['address'] = ['street', 'postal_code', 'city', 'country'];
107107
}
108108
$this->_table = $table;
109+
110+
$this->_Geocoder = new Geocoder($this->_config);
109111
}
110112

111113
/**
@@ -249,7 +251,6 @@ protected function _geocode($entity, array $addressData) {
249251
$entityData[$this->_config['lat']] = $address->getLatitude();
250252
$entityData[$this->_config['lng']] = $address->getLongitude();
251253

252-
//debug($address);die();
253254
if (!empty($this->_config['formatted_address'])) {
254255
// Unfortunately, the formatted address of google is lost
255256
$formatter = new StringFormatter();
@@ -450,8 +451,6 @@ public function validateLongitude($longitude) {
450451
* @throws \RuntimeException
451452
*/
452453
protected function _execute($address) {
453-
$this->_Geocoder = new Geocoder($this->_config);
454-
455454
/** @var \Geo\Model\Table\GeocodedAddressesTable|null $GeocodedAddresses */
456455
$GeocodedAddresses = null;
457456
if ($this->getConfig('cache')) {

0 commit comments

Comments
 (0)