diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..695983e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+; top-most EditorConfig file
+root = true
+
+; Unix-style newlines
+[*]
+end_of_line = LF
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+
+[{*.yml, *.yaml}]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.adoc]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..33e248e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,62 @@
+# Path-based git attributes
+# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
+# Auto detect text files and perform LF normalization
+* text eol=lf
+
+# (binary is a macro for -text -diff)
+*.br binary
+*.png binary
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.gz binary
+*.ico binary
+*.mov binary
+*.mp4 binary
+*.mp3 binary
+*.flv binary
+*.fla binary
+*.swf binary
+*.gz binary
+*.zip binary
+*.7z binary
+*.ttf binary
+*.otf binary
+*.eot binary
+*.woff binary
+*.woff2 binary
+*.pyc binary
+*.pdf binary
+
+# Ignore hidden files & directories
+/.editorconfig export-ignore
+/.env export-ignore
+/.env.example export-ignore
+/.eslintrc export-ignore
+/.eslintignore export-ignore
+/.gitattributes export-ignore
+/.gitignore export-ignore
+/.gitlab-ci.yml export-ignore
+/.gitmodules export-ignore
+/.idea export-ignore
+/.stylelintignore export-ignore
+/.stylelintrc.json export-ignore
+
+# Ignore directories
+/.githooks export-ignore
+/dev export-ignore
+/gulp-tasks export-ignore
+/node_modules export-ignore
+/vendor export-ignore
+
+# Ignore files
+/docker-compose.yml export-ignore
+/fractal.config.js export-ignore
+/gulpfile.js export-ignore
+/package.json export-ignore
+/package-lock.json export-ignore
+/phpcs.xml export-ignore
+/phpmd.xml export-ignore
+/phpunit.php export-ignore
+/phpunit.xml export-ignore
+/README.adoc export-ignore
diff --git a/.gitignore b/.gitignore
index e69de29..485dee6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea
diff --git a/Classes/Domain/Model/FormElements/Geoselect.php b/Classes/Domain/Model/FormElements/Geoselect.php
index 19ee57f..b78ff68 100644
--- a/Classes/Domain/Model/FormElements/Geoselect.php
+++ b/Classes/Domain/Model/FormElements/Geoselect.php
@@ -162,16 +162,16 @@ public function initializeFormElement()
// Include google maps javascript if enabled.
if (!empty($settings['googleMaps']['includeJs']) && !empty($settings['googleMaps']['apiKey'])) {
- $googleMapsParameters = [
+ $googleMapsParameters = [
'key' => $settings['googleMaps']['apiKey'],
'language' => $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode(),
];
- $GLOBALS['TSFE']->additionalFooterData['tx_twgeo_google_maps_js'] = '';
+ $GLOBALS['TSFE']->additionalFooterData['tx_twgeo_google_maps_js'] = '';
$GLOBALS['TSFE']->additionalFooterData['tx_twgeo_google_geoselect_js'] = '';
}
$this->setProperty(
'mapMarker',
- GeneralUtility::getIndpEnv('TYPO3_SITE_URL').$settings['googleMaps']['mapMarker']
+ GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $settings['googleMaps']['mapMarker']
);
$this->setProperty(
'mapCenter',
@@ -186,7 +186,7 @@ public function initializeFormElement()
// Add search field
- $this->searchField = $this->createElement($this->identifier.'-search', 'Text');
+ $this->searchField = $this->createElement($this->identifier . '-search', 'Text');
// $this->searchField->setLabel(
// LocalizationUtility::translate(
// 'LLL:EXT:tw_geo/Resources/Private/Language/locallang_forms.xlf:geoselect.search.label',
@@ -195,10 +195,10 @@ public function initializeFormElement()
// );
// Add hidden latitude;longitude field
- $this->latLonField = $this->createElement($this->identifier.'-lat-lon', 'Hidden');
+ $this->latLonField = $this->createElement($this->identifier . '-lat-lon', 'Hidden');
// Add position field for selection found positions based on the search result. Only used in non-js version.
- $this->positionField = $this->createElement($this->identifier.'-position', 'SingleSelect');
+ $this->positionField = $this->createElement($this->identifier . '-position', 'SingleSelect');
$this->positionField->setLabel(
LocalizationUtility::translate(
'LLL:EXT:tw_geo/Resources/Private/Language/locallang_forms.xlf:geoselect.positions.label',
diff --git a/Classes/Domain/Model/FormElements/StaticMap.php b/Classes/Domain/Model/FormElements/StaticMap.php
index cfdeeae..7d233d9 100644
--- a/Classes/Domain/Model/FormElements/StaticMap.php
+++ b/Classes/Domain/Model/FormElements/StaticMap.php
@@ -56,13 +56,13 @@ class StaticMap extends GenericFormElement
* @var array
*/
protected $properties = [
- 'latitude' => 0,
+ 'latitude' => 0,
'longitude' => 0,
- 'zoom' => 10,
- 'apiKey' => '',
- 'size' => '640x320',
- 'scale' => 2,
- 'maptype' => 'roadmap',
+ 'zoom' => 10,
+ 'apiKey' => '',
+ 'size' => '640x320',
+ 'scale' => 2,
+ 'maptype' => 'roadmap',
];
/**
@@ -75,8 +75,8 @@ class StaticMap extends GenericFormElement
public function initializeFormElement()
{
// Get typoscript settings for tw_geo
- $settings = GeneralUtility::makeInstance(ConfigurationManager::class)
- ->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
+ $settings = GeneralUtility::makeInstance(ConfigurationManager::class)
+ ->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$googleMapsSettings = $settings['plugin.']['tx_twgeo.']['settings.']['googleMaps.'];
$this->setProperty('apiKey', $googleMapsSettings['apiKey']);
}
diff --git a/Classes/Domain/Model/Position.php b/Classes/Domain/Model/Position.php
index f14b359..f78bee7 100644
--- a/Classes/Domain/Model/Position.php
+++ b/Classes/Domain/Model/Position.php
@@ -45,120 +45,108 @@
*/
class Position
{
+ /**
+ * Country display name part
+ *
+ * @var int
+ */
+ const COUNTRY = 1;
+ /**
+ * Region display name part
+ *
+ * @var int
+ */
+ const REGION = 2;
+ /**
+ * Locality display name part
+ *
+ * @var int
+ */
+ const LOCALITY = 4;
+ /**
+ * Street display name part
+ *
+ * @var int
+ */
+ const STREET = 8;
/**
* Country code
*
* @var string
*/
protected $countryCode = null;
-
/**
* Country name
*
* @var string
*/
protected $countryName = null;
-
/**
* Region
*
* @var string
*/
protected $region = null;
-
/**
* Locality
*
* @var string
*/
protected $locality = null;
-
/**
* Postal code
*
* @var string
*/
protected $postalCode = null;
-
/**
* Street address
*
* @var string
*/
protected $street = null;
-
/**
* Street number
*
* @var string
*/
protected $streetNumber = null;
-
/**
* Latitude
*
* @var float|null
*/
protected $latitude = null;
-
/**
* Longitude
*
* @var float
*/
protected $longitude = null;
-
/**
* Display name
*
* @var string
*/
protected $displayName = null;
-
/**
* If true, this position is a debug position
*
* @var bool
*/
protected $debug = false;
-
/**
* Service class
*
* @var string
*/
protected $serviceClass = null;
-
/**
* If true, position was retrieved from the frontend user session
*
* @var bool
*/
protected $fromSession = false;
- /**
- * Country display name part
- *
- * @var int
- */
- const COUNTRY = 1;
- /**
- * Region display name part
- *
- * @var int
- */
- const REGION = 2;
- /**
- * Locality display name part
- *
- * @var int
- */
- const LOCALITY = 4;
- /**
- * Street display name part
- *
- * @var int
- */
- const STREET = 8;
/**
* Constructor
@@ -193,83 +181,74 @@ public function setCountryCode(string $countryCode = null)
}
/**
- * Return the country name
+ * Return the postal code
*
- * @return string Country name
+ * @return string Postal code
*/
- public function getCountryName(): ?string
+ public function getPostalCode(): ?string
{
- return $this->countryName;
+ return $this->postalCode;
}
/**
- * Set the country name
+ * Set the postal code
*
- * @param string $countryName Country name
+ * @param string $postalCode Postal code
*/
- public function setCountryName(string $countryName = null)
+ public function setPostalCode(string $postalCode = null)
{
- $this->countryName = $countryName;
+ $this->postalCode = $postalCode;
}
/**
- * Return the region
+ * Return the street number
*
- * @return string Region
+ * @return string Street number
*/
- public function getRegion(): ?string
+ public function getStreetNumber(): string
{
- return $this->region;
+ return $this->streetNumber;
}
/**
- * Set the region
+ * Set the street number
*
- * @param string $region Region
+ * @param string $streetNumber Street number
*/
- public function setRegion(string $region = null)
+ public function setStreetNumber(string $streetNumber = null)
{
- $this->region = $region;
+ $this->streetNumber = $streetNumber;
}
/**
- * Return the Location
+ * Return the display name
*
- * @return string Location
- */
- public function getLocality(): ?string
- {
- return $this->locality;
- }
-
- /**
- * Set the location
+ * Control the display name parts to return by providing a part combination constant
*
- * @param string $locality Location
+ * @return string Display name
*/
- public function setLocality(string $locality = null)
+ public function getDisplayName(int $parts = self::COUNTRY | self::LOCALITY | self::REGION | self::STREET): string
{
- $this->locality = $locality;
- }
+ if ($parts == (self::COUNTRY | self::LOCALITY | self::REGION | self::STREET)) {
+ return $this->displayName;
+ }
- /**
- * Return the postal code
- *
- * @return string Postal code
- */
- public function getPostalCode(): ?string
- {
- return $this->postalCode;
+ return implode(', ', array_filter([
+ ($parts & self::STREET) ? $this->getStreet() : null,
+ ($parts & self::LOCALITY) ? $this->getLocality() : null,
+ ($parts & self::REGION) ? $this->getRegion() : null,
+ ($parts & self::COUNTRY) ? $this->getCountryName() : null,
+ ]));
}
/**
- * Set the postal code
+ * Set the display name
*
- * @param string $postalCode Postal code
+ * @param string $displayName Display name
*/
- public function setPostalCode(string $postalCode = null)
+ public function setDisplayName(string $displayName = null)
{
- $this->postalCode = $postalCode;
+ $this->displayName = $displayName;
}
/**
@@ -293,54 +272,63 @@ public function setStreet(string $street = null)
}
/**
- * Return the street number
+ * Return the Location
*
- * @return string Street number
+ * @return string Location
*/
- public function getStreetNumber(): string
+ public function getLocality(): ?string
{
- return $this->streetNumber;
+ return $this->locality;
}
/**
- * Set the street number
+ * Set the location
*
- * @param string $streetNumber Street number
+ * @param string $locality Location
*/
- public function setStreetNumber(string $streetNumber = null)
+ public function setLocality(string $locality = null)
{
- $this->streetNumber = $streetNumber;
+ $this->locality = $locality;
}
/**
- * Return the display name
+ * Return the region
*
- * Control the display name parts to return by providing a part combination constant
+ * @return string Region
+ */
+ public function getRegion(): ?string
+ {
+ return $this->region;
+ }
+
+ /**
+ * Set the region
*
- * @return string Display name
+ * @param string $region Region
*/
- public function getDisplayName(int $parts = self::COUNTRY | self::LOCALITY | self::REGION | self::STREET): string
+ public function setRegion(string $region = null)
{
- if ($parts == (self::COUNTRY | self::LOCALITY | self::REGION | self::STREET)) {
- return $this->displayName;
- }
+ $this->region = $region;
+ }
- return implode(', ', array_filter([
- ($parts & self::STREET) ? $this->getStreet() : null,
- ($parts & self::LOCALITY) ? $this->getLocality() : null,
- ($parts & self::REGION) ? $this->getRegion() : null,
- ($parts & self::COUNTRY) ? $this->getCountryName() : null,
- ]));
+ /**
+ * Return the country name
+ *
+ * @return string Country name
+ */
+ public function getCountryName(): ?string
+ {
+ return $this->countryName;
}
/**
- * Set the display name
+ * Set the country name
*
- * @param string $displayName Display name
+ * @param string $countryName Country name
*/
- public function setDisplayName(string $displayName = null)
+ public function setCountryName(string $countryName = null)
{
- $this->displayName = $displayName;
+ $this->countryName = $countryName;
}
/**
diff --git a/Classes/Domain/Model/PositionList.php b/Classes/Domain/Model/PositionList.php
index 00a0e21..a3d4125 100644
--- a/Classes/Domain/Model/PositionList.php
+++ b/Classes/Domain/Model/PositionList.php
@@ -36,6 +36,9 @@
namespace Tollwerk\TwGeo\Domain\Model;
+use ArrayIterator;
+use IteratorIterator;
+
/**
* Position List
*
@@ -45,7 +48,7 @@
* @package Tollwerk\TwGeo
* @subpackage Tollwerk\TwGeo\Domain\Model
*/
-class PositionList extends \IteratorIterator
+class PositionList extends IteratorIterator
{
/**
* Constructor
@@ -54,7 +57,7 @@ class PositionList extends \IteratorIterator
*/
public function __construct(Position ...$positions)
{
- parent::__construct(new \ArrayIterator($positions));
+ parent::__construct(new ArrayIterator($positions));
}
/**
diff --git a/Classes/Hook/FormHook.php b/Classes/Hook/FormHook.php
index 4123f21..5bdb005 100644
--- a/Classes/Hook/FormHook.php
+++ b/Classes/Hook/FormHook.php
@@ -41,6 +41,7 @@
use Tollwerk\TwGeo\Domain\Model\PositionList;
use Tollwerk\TwGeo\Utility\GeoUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
/**
@@ -49,18 +50,33 @@
*/
class FormHook
{
+ /**
+ * @param FormRuntime $formRuntime
+ * @param RootRenderableInterface $renderable
+ *
+ * @return void
+ */
+ public function beforeRendering(
+ FormRuntime $formRuntime,
+ RootRenderableInterface $renderable
+ ) {
+ if ($renderable->getType() == 'Geoselect') {
+ $this->checkGeoselectField($formRuntime, $renderable);
+ }
+ }
+
/**
* Check the geo select field
*
* @param FormRuntime $formRuntime
- * @param Geoselect $renderable
+ * @param Geoselect $renderable
*
* @return bool
*/
protected function checkGeoselectField(FormRuntime $formRuntime, Geoselect $renderable)
{
// If no search string is given, we can abort all further processing
- $searchString = $formRuntime->getElementValue($renderable->getIdentifier().'-search');
+ $searchString = $formRuntime->getElementValue($renderable->getIdentifier() . '-search');
if (!$searchString) {
return false;
}
@@ -76,29 +92,14 @@ protected function checkGeoselectField(FormRuntime $formRuntime, Geoselect $rend
if ($positions->count()) {
$positions->rewind();
$firstPosition = $positions->current();
- $renderable->setLatLon($firstPosition->getLatitude().','.$firstPosition->getLongitude());
+ $renderable->setLatLon($firstPosition->getLatitude() . ',' . $firstPosition->getLongitude());
}
}
- $latLon = $formRuntime->getElementValue($renderable->getIdentifier().'-position');
+ $latLon = $formRuntime->getElementValue($renderable->getIdentifier() . '-position');
if ($latLon) {
$renderable->setLatLon($latLon);
}
}
-
- /**
- * @param \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime
- * @param \TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface $renderable
- *
- * @return void
- */
- public function beforeRendering(
- \TYPO3\CMS\Form\Domain\Runtime\FormRuntime $formRuntime,
- \TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface $renderable
- ) {
- if ($renderable->getType() == 'Geoselect') {
- $this->checkGeoselectField($formRuntime, $renderable);
- }
- }
}
diff --git a/Classes/Service/Geocoding/AbstractGeocodingService.php b/Classes/Service/Geocoding/AbstractGeocodingService.php
index 0e15494..a816a87 100644
--- a/Classes/Service/Geocoding/AbstractGeocodingService.php
+++ b/Classes/Service/Geocoding/AbstractGeocodingService.php
@@ -46,12 +46,6 @@
*/
abstract class AbstractGeocodingService extends AbstractService implements GeocodingInterface
{
- /**
- * HTTP Headers
- *
- * @var array
- */
- protected $httpRequestHeader = ['User-Agent: tollwerk/TYPO3-ext-tw_geo'];
/**
* Country to language mapping
*
@@ -309,6 +303,12 @@ abstract class AbstractGeocodingService extends AbstractService implements Geoco
'ZM' => ['en'],
'ZW' => ['en', 'sn', 'nd']
];
+ /**
+ * HTTP Headers
+ *
+ * @var array
+ */
+ protected $httpRequestHeader = ['User-Agent: tollwerk/TYPO3-ext-tw_geo'];
/**
* Return the current frontend language
diff --git a/Classes/Service/Geocoding/GeocodingInterface.php b/Classes/Service/Geocoding/GeocodingInterface.php
index c5a57c4..3885b37 100644
--- a/Classes/Service/Geocoding/GeocodingInterface.php
+++ b/Classes/Service/Geocoding/GeocodingInterface.php
@@ -29,6 +29,7 @@
use Tollwerk\TwGeo\Domain\Model\Position;
use Tollwerk\TwGeo\Domain\Model\PositionList;
+use Traversable;
interface GeocodingInterface
{
@@ -37,17 +38,17 @@ interface GeocodingInterface
*
* @param string $queryString
*
- * @return \Traversable
+ * @return Traversable
*/
public function geocode(string $queryString = null): ?PositionList;
/**
* Reverse geocode a set of coordinates
*
- * @param float $latitude Latitude
- * @param float $longitude Longitude
- * @param int $zoom Zoom level
- * @param array|string|null $language Language
+ * @param float $latitude Latitude
+ * @param float $longitude Longitude
+ * @param int $zoom Zoom level
+ * @param array|string|null $language Language
*
* @return Position|null Position
*/
diff --git a/Classes/Service/Geocoding/GoogleMapsService.php b/Classes/Service/Geocoding/GoogleMapsService.php
index c3ad984..a4ec44e 100644
--- a/Classes/Service/Geocoding/GoogleMapsService.php
+++ b/Classes/Service/Geocoding/GoogleMapsService.php
@@ -35,6 +35,7 @@
namespace Tollwerk\TwGeo\Service\Geocoding;
+use stdClass;
use Tollwerk\TwGeo\Domain\Model\Position;
use Tollwerk\TwGeo\Domain\Model\PositionList;
use Tollwerk\TwGeo\Utility\CurlUtility;
@@ -48,6 +49,12 @@
*/
class GoogleMapsService extends AbstractGeocodingService
{
+ /**
+ * Status
+ *
+ * @var string
+ */
+ const STATUS_OK = 'OK';
/**
* Google Maps API key
*
@@ -60,12 +67,6 @@ class GoogleMapsService extends AbstractGeocodingService
* @var string
*/
protected $baseUrl = 'https://maps.googleapis.com/maps/api/geocode/json?';
- /**
- * Status
- *
- * @var string
- */
- const STATUS_OK = 'OK';
/**
* Initialization of the service.
@@ -105,14 +106,14 @@ public function geocode(string $address = null): ?PositionList
'key' => $this->apiKey,
'language' => ($language = $this->getCurrentFrontendLanguage()) ? $language->getTwoLetterIsoCode() : 'en',
];
- $requestUri = $this->baseUrl.'&'.http_build_query($parameters);
+ $requestUri = $this->baseUrl . '&' . http_build_query($parameters);
$result = CurlUtility::httpRequest($requestUri, $this->httpRequestHeader);
$data = json_decode($result);
// Return results
if ($data->status == self::STATUS_OK && count($data->results)) {
$positions = new PositionList();
- /** @var \stdClass $result */
+ /** @var stdClass $result */
foreach ($data->results as $result) {
$position = new Position($result->geometry->location->lat, $result->geometry->location->lng);
$position->setServiceClass(self::class);
@@ -155,10 +156,10 @@ public function geocode(string $address = null): ?PositionList
/**
* Reverse geocode a set of coordinates
*
- * @param float $latitude Latitude
- * @param float $longitude Longitude
- * @param int $zoom Zoom level
- * @param array|string|null $language Language
+ * @param float $latitude Latitude
+ * @param float $longitude Longitude
+ * @param int $zoom Zoom level
+ * @param array|string|null $language Language
*
* @return Position|null Position
*/
diff --git a/Classes/Service/Geocoding/OpenStreetMapService.php b/Classes/Service/Geocoding/OpenStreetMapService.php
index 9f4f174..5ccabf7 100644
--- a/Classes/Service/Geocoding/OpenStreetMapService.php
+++ b/Classes/Service/Geocoding/OpenStreetMapService.php
@@ -36,6 +36,7 @@
namespace Tollwerk\TwGeo\Service\Geocoding;
+use stdClass;
use Tollwerk\TwGeo\Domain\Model\Position;
use Tollwerk\TwGeo\Domain\Model\PositionList;
use Tollwerk\TwGeo\Utility\CurlUtility;
@@ -75,12 +76,12 @@ public function geocode(string $address = null): ?PositionList
'accept-language' => ($language = $this->getCurrentFrontendLanguage()) ? $language->getTwoLetterIsoCode() : 'en',
];
- $requestUri = $this->geocodeUrl.'&'.http_build_query($parameters);
+ $requestUri = $this->geocodeUrl . '&' . http_build_query($parameters);
$result = CurlUtility::httpRequest($requestUri, $this->httpRequestHeader);
$data = json_decode($result);
if (is_array($data) && count($data)) {
$positions = new PositionList();
- /** @var \stdClass $result */
+ /** @var stdClass $result */
foreach ($data as $result) {
$address = $result->address;
$position = new Position($result->lat, $result->lon);
@@ -103,10 +104,10 @@ public function geocode(string $address = null): ?PositionList
/**
* Reverse geocode a set of coordinates
*
- * @param float $latitude Latitude
- * @param float $longitude Longitude
- * @param int $zoom Zoom level
- * @param array|string|null $language Language
+ * @param float $latitude Latitude
+ * @param float $longitude Longitude
+ * @param int $zoom Zoom level
+ * @param array|string|null $language Language
*
* @return Position|null Position
*/
@@ -125,7 +126,7 @@ public function reverseGeocode(
if (!empty($languages)) {
$parameters['accept-language'] = implode(',', $languages);
}
- $requestUri = $this->reverseGeocodeUrl.'&'.http_build_query($parameters);
+ $requestUri = $this->reverseGeocodeUrl . '&' . http_build_query($parameters);
$status = null;
$result = CurlUtility::httpRequest(
$requestUri,
@@ -173,7 +174,7 @@ protected function detectLanguage(float $latitude, float $longitude): ?array
'lon' => $longitude,
'zoom' => 3
];
- $requestUri = $this->reverseGeocodeUrl.'&'.http_build_query($parameters);
+ $requestUri = $this->reverseGeocodeUrl . '&' . http_build_query($parameters);
$status = null;
$result = CurlUtility::httpRequest(
$requestUri,
diff --git a/Classes/Service/Geolocation/GeoiplookupService.php b/Classes/Service/Geolocation/GeoiplookupService.php
index a5ff998..6d47943 100644
--- a/Classes/Service/Geolocation/GeoiplookupService.php
+++ b/Classes/Service/Geolocation/GeoiplookupService.php
@@ -27,6 +27,7 @@
namespace Tollwerk\TwGeo\Service\Geolocation;
+use Error;
use Tollwerk\TwGeo\Domain\Model\Position;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -77,7 +78,7 @@ public function getGeolocation(string $ip = null): ?Position
$position->setLongitude($result[7]);
return $position->getLatitude() && $position->getLongitude() ? $position : null;
- } catch (\Error $error) {
+ } catch (Error $error) {
return null;
}
}
diff --git a/Classes/Service/Geolocation/GeolocationInterface.php b/Classes/Service/Geolocation/GeolocationInterface.php
index 76a568e..8b98e24 100644
--- a/Classes/Service/Geolocation/GeolocationInterface.php
+++ b/Classes/Service/Geolocation/GeolocationInterface.php
@@ -32,6 +32,7 @@ interface GeolocationInterface
{
/**
* Get geolocation of the user IP address
+ *
* @param string|null $ip
*
* @return null|Position
diff --git a/Classes/Service/Geolocation/PhpGeoIPService.php b/Classes/Service/Geolocation/PhpGeoIPService.php
index b0ebd7a..80bf3cf 100644
--- a/Classes/Service/Geolocation/PhpGeoIPService.php
+++ b/Classes/Service/Geolocation/PhpGeoIPService.php
@@ -27,6 +27,7 @@
namespace Tollwerk\TwGeo\Service\Geolocation;
+use Error;
use Tollwerk\TwGeo\Domain\Model\Position;
class PhpGeoIPService extends AbstractGeolocationService
@@ -55,7 +56,7 @@ public function getGeolocation(string $ip = null): ?Position
}
return null;
- } catch (\Error $error) {
+ } catch (Error $error) {
return null;
}
}
diff --git a/Classes/Utility/CurlUtility.php b/Classes/Utility/CurlUtility.php
index 217102a..3070854 100644
--- a/Classes/Utility/CurlUtility.php
+++ b/Classes/Utility/CurlUtility.php
@@ -10,12 +10,6 @@
*/
class CurlUtility
{
- /**
- * SSL certificate validation
- *
- * @var boolean
- */
- protected static $_verify = true;
/**
* GET request
*
@@ -40,6 +34,12 @@ class CurlUtility
* @var string
*/
const PUT = 'PUT';
+ /**
+ * SSL certificate validation
+ *
+ * @var boolean
+ */
+ protected static $_verify = true;
/**
* Enable / disable the SSL certificate validation
@@ -58,12 +58,12 @@ public static function setVerify($verify = true)
/**
* Make a HTTP request
*
- * @param string $url Endpoint / URL
- * @param array $header Header
- * @param string $method Method
- * @param string $body Body
- * @param boolean $debug Output debugging information
- * @param int $httpStatus HTTP status code
+ * @param string $url Endpoint / URL
+ * @param array $header Header
+ * @param string $method Method
+ * @param string $body Body
+ * @param boolean $debug Output debugging information
+ * @param int $httpStatus HTTP status code
*
* @return string Result
*/
diff --git a/Classes/ViewHelpers/Format/DistanceViewHelper.php b/Classes/ViewHelpers/Format/DistanceViewHelper.php
index 475e2ef..67f1044 100644
--- a/Classes/ViewHelpers/Format/DistanceViewHelper.php
+++ b/Classes/ViewHelpers/Format/DistanceViewHelper.php
@@ -36,6 +36,7 @@
namespace Tollwerk\TwGeo\ViewHelpers\Format;
+use Closure;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@@ -50,31 +51,35 @@ class DistanceViewHelper extends AbstractViewHelper
];
/**
- * Initialize arguments
- */
- public function initializeArguments()
- {
- parent::initializeArguments();
- $this->registerArgument('startUnitOffset', 'integer', '0 = meters. 1 = kilometer etc. Step is 1000.', false, 0);
- }
-
- /**
- * @param array $arguments
- * @param \Closure $renderChildrenClosure
+ * @param array $arguments
+ * @param Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return bool
*/
- public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
- {
- $value = intval($renderChildrenClosure());
+ public static function renderStatic(
+ array $arguments,
+ Closure $renderChildrenClosure,
+ RenderingContextInterface $renderingContext
+ ) {
+ $value = intval($renderChildrenClosure());
$currentUnitIndex = isset($arguments['startUnitOffset']) ? intval($arguments['startUnitOffset']) : 0;
- $unit = self::$units[$currentUnitIndex];
+ $unit = self::$units[$currentUnitIndex];
while (($newValue = $value / 1000) >= 1 && array_key_exists(++$currentUnitIndex, self::$units)) {
$value = floor($newValue);
- $unit = self::$units[$currentUnitIndex];
+ $unit = self::$units[$currentUnitIndex];
}
- return $value.' '.$unit;
+
+ return $value . ' ' . $unit;
+ }
+
+ /**
+ * Initialize arguments
+ */
+ public function initializeArguments()
+ {
+ parent::initializeArguments();
+ $this->registerArgument('startUnitOffset', 'integer', '0 = meters. 1 = kilometer etc. Step is 1000.', false, 0);
}
-}
\ No newline at end of file
+}
diff --git a/Classes/ViewHelpers/GeolocationViewHelper.php b/Classes/ViewHelpers/GeolocationViewHelper.php
index 76d7eb6..42aee9c 100644
--- a/Classes/ViewHelpers/GeolocationViewHelper.php
+++ b/Classes/ViewHelpers/GeolocationViewHelper.php
@@ -36,6 +36,7 @@
namespace Tollwerk\TwGeo\ViewHelpers;
+use Closure;
use Tollwerk\TwGeo\Utility\GeoUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
@@ -48,16 +49,20 @@
class GeolocationViewHelper extends AbstractViewHelper
{
/**
- * @param array $arguments
- * @param \Closure $renderChildrenClosure
+ * @param array $arguments
+ * @param Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return bool
*/
- public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
- {
+ public static function renderStatic(
+ array $arguments,
+ Closure $renderChildrenClosure,
+ RenderingContextInterface $renderingContext
+ ) {
/** @var GeoUtility $geoUtility */
$geoUtility = GeneralUtility::makeInstance(GeoUtility::class);
+
return $geoUtility->getGeoLocation();
}
-}
\ No newline at end of file
+}