Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aurélien FOUCRET
committed
Nov 29, 2016
0 parents
commit 27ac8ad
Showing
34 changed files
with
2,250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Api\Data; | ||
|
||
interface AddressInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Api\Data; | ||
|
||
interface GeoPointInterface | ||
{ | ||
/** | ||
* @return float | ||
*/ | ||
public function getLatitude(); | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getLongitude(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Api; | ||
|
||
interface MapInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getIdentifier(); | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Api; | ||
|
||
interface MapProviderInterface | ||
{ | ||
/** | ||
* @return MapInteface | ||
*/ | ||
public function getMap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Helper; | ||
|
||
use Magento\Framework\App\Helper\AbstractHelper; | ||
|
||
class Map extends AbstractHelper | ||
{ | ||
const MAP_CONFIG_XML_PATH = 'smile_map/map'; | ||
|
||
const SHARED_SETTINGS_NAME = 'all'; | ||
|
||
public function getProviderIdentifier() | ||
{ | ||
return $this->scopeConfig->getValue(self::MAP_CONFIG_XML_PATH . '/provider'); | ||
} | ||
|
||
public function getProviderConfiguration($providerIdentifier) | ||
{ | ||
$config = []; | ||
|
||
$mapKeyFunc = function(&$value, $key) use (&$config, $providerIdentifier) { | ||
if (strpos($key, 'provider_' .$providerIdentifier) === 0 || strpos($key, 'provider_' .self::SHARED_SETTINGS_NAME) === 0) { | ||
$prefixes = ['provider_' .$providerIdentifier . '_', 'provider_' .self::SHARED_SETTINGS_NAME . '_']; | ||
$key = str_replace($prefixes, '', $key); | ||
$config[$key] = $value; | ||
} | ||
}; | ||
|
||
$allConfig = $this->scopeConfig->getValue(self::MAP_CONFIG_XML_PATH); | ||
array_walk($allConfig, $mapKeyFunc); | ||
|
||
return $config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Model; | ||
|
||
use Smile\Map\Api\Data\GeoPointInterface; | ||
|
||
class GeoPoint implements GeoPointInterface | ||
{ | ||
/** | ||
* @var float | ||
*/ | ||
private $latitude; | ||
|
||
/** | ||
* @var float | ||
*/ | ||
private $longitude; | ||
|
||
/** | ||
* | ||
* @param float $latitude | ||
* @param float $longitude | ||
*/ | ||
public function __construct($latitude, $longitude) | ||
{ | ||
$this->latitude = $latitude; | ||
$this->longitude = $longitude; | ||
} | ||
|
||
public function getLatitude() | ||
{ | ||
return $this->getLatitude(); | ||
} | ||
|
||
public function getLongitude() | ||
{ | ||
return $this->getLongitude(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Model\Map; | ||
|
||
use \Smile\Map\Helper\Map as MapHelper; | ||
|
||
class DefaultMap implements \Smile\Map\Api\MapInterface | ||
{ | ||
private $identifier; | ||
|
||
private $config; | ||
|
||
public function __construct($identifier, MapHelper $mapHelper) | ||
{ | ||
$this->identifier = $identifier; | ||
$this->config = $mapHelper->getProviderConfiguration($identifier); | ||
} | ||
|
||
public function getConfig() | ||
{ | ||
return $this->config; | ||
} | ||
|
||
public function getIdentifier() | ||
{ | ||
return $this->identifier; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Smile\Map\Model; | ||
|
||
use Smile\Map\Api\MapProviderInterface; | ||
use Smile\Map\Helper\Map as MapHelper; | ||
|
||
class MapProvider implements MapProviderInterface | ||
{ | ||
/** | ||
* @var \Smile\Map\Api\MapInterface[] | ||
*/ | ||
private $mapProviders; | ||
|
||
/** | ||
* @var MapHelper | ||
*/ | ||
private $mapHelper; | ||
|
||
/** | ||
* Contructor. | ||
* | ||
* @param \Smile\Map\Api\MapInterface[] $mapProviders | ||
*/ | ||
public function __construct(MapHelper $mapHelper, array $mapProviders = []) | ||
{ | ||
$this->mapHelper = $mapHelper; | ||
$this->mapProviders = $mapProviders; | ||
} | ||
|
||
public function getMap() | ||
{ | ||
$providerIdentifier = $this->mapHelper->getProviderIdentifier(); | ||
|
||
if (!isset($this->mapProviders[$providerIdentifier])) { | ||
throw new \LogicException(__("Map provider %s does not exists", $providerIdentifier)); | ||
} | ||
|
||
return $this->mapProviders[$providerIdentifier]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "smile/module-map", | ||
"type": "magento2-module", | ||
"description": "Smile Map Utilities Module", | ||
"keywords": ["magento2", "map", "geocoding", "geolocalisation"], | ||
"require": { | ||
"php": "~5.5.0|~5.6.0|~7.0.0", | ||
"magento/framework": "*", | ||
"magento/module-store": "*", | ||
"willdurand/geocoder": "^3.3" | ||
}, | ||
"license": "OSL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Aurélien FOUCRET", | ||
"email": "aurelien.foucret@smile.fr" | ||
}, | ||
{ | ||
"name": "Romain Ruaud", | ||
"email": "romain.ruaud@smile.fr" | ||
}, | ||
{ | ||
"name": "Guillaume Vrac", | ||
"email": "guillaume.vrac@smile.fr" | ||
} | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Smile\\Map\\" : "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Default Configuration for Localized Retailer | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\Smile_LocalizedRetailer | ||
* @author Romain RUAUD <romain.ruaud@smile.fr> | ||
* @copyright 2016 Smile | ||
* @license Apache License Version 2.0 | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> | ||
<default> | ||
<smile_map> | ||
<map> | ||
<provider>google</provider> | ||
|
||
<provider_osm_tile_url>http://{s}.tile.osm.org/{z}/{x}/{y}.png</provider_osm_tile_url> | ||
|
||
<provider_google_api_key>AIzaSyDBeZ4JyDqP4ZTHk2tnUauKEbLgwOHYlC8</provider_google_api_key> | ||
<provider_google_type>roadmap</provider_google_type> | ||
</map> | ||
</smile_map> | ||
</default> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Store Locator Dependency Injection | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\StoreLocator | ||
* @author Romain RUAUD <romain.ruaud@smile.fr> | ||
* @copyright 2016 Smile | ||
* @license Apache License Version 2.0 | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
|
||
<!-- Models --> | ||
<preference for="Smile\Map\Api\MapProviderInterface" type="Smile\Map\Model\MapProvider" /> | ||
|
||
<virtualType name="Smile\Map\Model\Map\Osm" type="Smile\Map\Model\Map\DefaultMap"> | ||
<arguments> | ||
<argument name="identifier" xsi:type="string">osm</argument> | ||
</arguments> | ||
</virtualType> | ||
|
||
<virtualType name="Smile\Map\Model\Map\Google" type="Smile\Map\Model\Map\DefaultMap"> | ||
<arguments> | ||
<argument name="identifier" xsi:type="string">google</argument> | ||
</arguments> | ||
</virtualType> | ||
|
||
<type name="Smile\Map\Model\MapProvider"> | ||
<arguments> | ||
<argument name="mapProviders" xsi:type="array"> | ||
<item name="osm" xsi:type="object">Smile\Map\Model\Map\Osm</item> | ||
<item name="google" xsi:type="object">Smile\Map\Model\Map\Google</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
|
||
<!-- | ||
<virtualType name="Smile\StoreLocator\Retailer\ImageUpload" type="Magento\Catalog\Model\ImageUploader"> | ||
<arguments> | ||
<argument name="baseTmpPath" xsi:type="string">retailer/tmp/image</argument> | ||
<argument name="basePath" xsi:type="string">seller</argument> | ||
<argument name="allowedExtensions" xsi:type="array"> | ||
<item name="jpg" xsi:type="string">jpg</item> | ||
<item name="jpeg" xsi:type="string">jpeg</item> | ||
<item name="gif" xsi:type="string">gif</item> | ||
<item name="png" xsi:type="string">png</item> | ||
</argument> | ||
</arguments> | ||
</virtualType> | ||
<type name="Smile\StoreLocator\Model\Retailer\Attribute\Backend\Image"> | ||
<arguments> | ||
<argument name="imageUploader" xsi:type="object">Smile\StoreLocator\Retailer\ImageUpload</argument> | ||
</arguments> | ||
</type> | ||
<type name="Smile\StoreLocator\Model\Retailer\Images\ReadHandler"> | ||
<arguments> | ||
<argument name="imagesAttributes" xsi:type="array"> | ||
<item name="image1" xsi:type="string">image1</item> | ||
<item name="image2" xsi:type="string">image2</item> | ||
<item name="image3" xsi:type="string">image3</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
<type name="Magento\Framework\EntityManager\Operation\ExtensionPool"> | ||
<arguments> | ||
<argument name="extensionActions" xsi:type="array"> | ||
<item name="Smile\Seller\Api\Data\SellerInterface" xsi:type="array"> | ||
<item name="read" xsi:type="array"> | ||
<item name="read_images" xsi:type="string">Smile\StoreLocator\Model\Retailer\Images\ReadHandler</item> | ||
</item> | ||
</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
--> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\Map | ||
* @author Romain Ruaud <romain.ruaud@smile.fr> | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2016 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Smile_Map" setup_version="1.0.0"> | ||
<sequence> | ||
<module name="Magento_Config"/> | ||
<module name="Magento_Store"/> | ||
</sequence> | ||
</module> | ||
</config> |
Oops, something went wrong.