Skip to content

Commit

Permalink
Move instantiation into constructor since stateless.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed May 22, 2018
1 parent f12be13 commit 781ed0f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Model/Behavior/GeocoderBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function __construct(Table $table, array $config = []) {
$this->_config['address'] = ['street', 'postal_code', 'city', 'country'];
}
$this->_table = $table;

$this->_Geocoder = new Geocoder($this->_config);
}

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

//debug($address);die();
if (!empty($this->_config['formatted_address'])) {
// Unfortunately, the formatted address of google is lost
$formatter = new StringFormatter();
Expand Down Expand Up @@ -450,8 +451,6 @@ public function validateLongitude($longitude) {
* @throws \RuntimeException
*/
protected function _execute($address) {
$this->_Geocoder = new Geocoder($this->_config);

/** @var \Geo\Model\Table\GeocodedAddressesTable|null $GeocodedAddresses */
$GeocodedAddresses = null;
if ($this->getConfig('cache')) {
Expand Down

0 comments on commit 781ed0f

Please sign in to comment.