diff --git a/build.properties b/build.properties index c3f919a..3dc111a 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,5 @@ phpcs.standard=${basedir}/vendor/contao-community-alliance/coding-standard/phpcs/ContaoCommunityAlliance/ruleset.xml phpmd.ruleset=${basedir}/vendor/contao-community-alliance/coding-standard/phpmd/ruleset.xml + +ccabs.bin.dir = ${basedir}/bin diff --git a/composer.json b/composer.json index 5c72060..4cdd9a4 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "contao-community-alliance/url-builder":"~1.1", "netzmacht/contao-leaflet-libraries": "~0.7", "netzmacht/php-javascript-builder": "~1.0", - "netzmacht/php-leaflet": "dev-master", + "netzmacht/php-leaflet": "~0.7", "netzmacht/contao-dev-tools":"~1.0", "bit3/contao-meta-palettes": "~1.5", "menatwork/contao-multicolumnwizard": "~3.2", diff --git a/module/config/autoload.php b/module/config/autoload.php index 7cdbc3d..299c6ab 100644 --- a/module/config/autoload.php +++ b/module/config/autoload.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + TemplateLoader::addFiles( array( 'ce_leaflet_map' => 'system/modules/leaflet/templates', diff --git a/module/config/config.php b/module/config/config.php index 70befe7..78271bd 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + /* * Backend module. */ diff --git a/module/config/event_subscribers.php b/module/config/event_subscribers.php index ad5cde2..59eac96 100644 --- a/module/config/event_subscribers.php +++ b/module/config/event_subscribers.php @@ -1,5 +1,13 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ return array( 'Netzmacht\Contao\Leaflet\Subscriber\BootSubscriber', 'Netzmacht\Contao\Leaflet\Subscriber\HashSubscriber', diff --git a/module/config/leaflet_providers.php b/module/config/leaflet_providers.php index d1764de..9ee521d 100644 --- a/module/config/leaflet_providers.php +++ b/module/config/leaflet_providers.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + /* * Support all providers and variants which are supported by leaflet-providers. * See https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js diff --git a/module/config/services.php b/module/config/services.php index c71dc94..95ee855 100644 --- a/module/config/services.php +++ b/module/config/services.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + use Netzmacht\Contao\Leaflet\Boot; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\MapService; diff --git a/module/dca/tl_content.php b/module/dca/tl_content.php index fe6f1d5..56d7def 100644 --- a/module/dca/tl_content.php +++ b/module/dca/tl_content.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array( 'type' => array('type', 'headline'), 'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'), @@ -13,9 +22,9 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_map'], 'inputType' => 'select', 'exclude' => true, - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Content', 'getMaps'), + 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getMaps'), 'wizard' => array( - array('Netzmacht\Contao\Leaflet\Dca\Content', 'getEditMapLink'), + array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getEditMapLink'), ), 'eval' => array( 'tl_class' => 'w50 wizard', diff --git a/module/dca/tl_leaflet_control.php b/module/dca/tl_leaflet_control.php index 8fc90d3..847ce46 100644 --- a/module/dca/tl_leaflet_control.php +++ b/module/dca/tl_leaflet_control.php @@ -1,5 +1,13 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ \Controller::loadLanguageFile('leaflet'); $GLOBALS['TL_DCA']['tl_leaflet_control'] = array diff --git a/module/dca/tl_leaflet_control_layer.php b/module/dca/tl_leaflet_control_layer.php index 858d27a..7f34dc3 100644 --- a/module/dca/tl_leaflet_control_layer.php +++ b/module/dca/tl_leaflet_control_layer.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_leaflet_control_layer'] = array ( 'config' => array( diff --git a/module/dca/tl_leaflet_icon.php b/module/dca/tl_leaflet_icon.php index eeb57f4..347255f 100644 --- a/module/dca/tl_leaflet_icon.php +++ b/module/dca/tl_leaflet_icon.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_leaflet_icon'] = array ( 'config' => array( diff --git a/module/dca/tl_leaflet_layer.php b/module/dca/tl_leaflet_layer.php index 3c5ef83..f1cd297 100644 --- a/module/dca/tl_leaflet_layer.php +++ b/module/dca/tl_leaflet_layer.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + \Controller::loadLanguageFile('leaflet'); $GLOBALS['TL_DCA']['tl_leaflet_layer'] = array diff --git a/module/dca/tl_leaflet_map.php b/module/dca/tl_leaflet_map.php index 1914f1f..18d5928 100644 --- a/module/dca/tl_leaflet_map.php +++ b/module/dca/tl_leaflet_map.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_leaflet_map'] = array ( 'config' => array( diff --git a/module/dca/tl_leaflet_map_layer.php b/module/dca/tl_leaflet_map_layer.php index 87ba6d6..8599fbe 100644 --- a/module/dca/tl_leaflet_map_layer.php +++ b/module/dca/tl_leaflet_map_layer.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_leaflet_map_layer'] = array ( 'config' => array( diff --git a/module/dca/tl_leaflet_marker.php b/module/dca/tl_leaflet_marker.php index ea7c5ca..cd68586 100644 --- a/module/dca/tl_leaflet_marker.php +++ b/module/dca/tl_leaflet_marker.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + \Controller::loadLanguageFile('leaflet'); diff --git a/module/dca/tl_leaflet_style.php b/module/dca/tl_leaflet_style.php index c2baf95..39a7e96 100644 --- a/module/dca/tl_leaflet_style.php +++ b/module/dca/tl_leaflet_style.php @@ -1,5 +1,13 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ $GLOBALS['TL_DCA']['tl_leaflet_style'] = array ( 'config' => array( diff --git a/module/dca/tl_leaflet_vector.php b/module/dca/tl_leaflet_vector.php index 12286bb..c7ad28f 100644 --- a/module/dca/tl_leaflet_vector.php +++ b/module/dca/tl_leaflet_vector.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + \Controller::loadLanguageFile('leaflet'); $GLOBALS['TL_DCA']['tl_leaflet_vector'] = array diff --git a/module/dca/tl_module.php b/module/dca/tl_module.php index f5bfd55..b8480af 100644 --- a/module/dca/tl_module.php +++ b/module/dca/tl_module.php @@ -1,5 +1,14 @@ + * @copyright 2014 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + $GLOBALS['TL_DCA']['tl_module']['metapalettes']['leaflet'] = array( 'type' => array('name', 'type', 'headline'), 'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'), @@ -13,9 +22,9 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_map'], 'inputType' => 'select', 'exclude' => true, - 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\Module', 'getMaps'), + 'options_callback' => array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getMaps'), 'wizard' => array( - array('Netzmacht\Contao\Leaflet\Dca\Module', 'getEditMapLink'), + array('Netzmacht\Contao\Leaflet\Dca\FrontendIntegration', 'getEditMapLink'), ), 'eval' => array( 'tl_class' => 'w50 wizard', diff --git a/src/Netzmacht/Contao/Leaflet/Backend/Credits.php b/src/Netzmacht/Contao/Leaflet/Backend/Credits.php index 351df6a..80ec6da 100644 --- a/src/Netzmacht/Contao/Leaflet/Backend/Credits.php +++ b/src/Netzmacht/Contao/Leaflet/Backend/Credits.php @@ -11,21 +11,37 @@ namespace Netzmacht\Contao\Leaflet\Backend; - +/** + * Credits backend module. + * + * @package Netzmacht\Contao\Leaflet\Backend + */ class Credits { + /** + * Generate the backend view. + * + * @return string + */ public function generate() { $template = new \BackendTemplate('be_leaflet_credits'); - $template->headline = 'Leaftlet maps integration for Contao CMS'; - $template->libraries = $this->getLibraries(); + $template->headline = 'Leaftlet maps integration for Contao CMS'; + $template->libraries = $this->getLibraries(); list($template->version, $template->dependencies) = $this->extractFromComposer(); return $template->parse(); } + /** + * Get list of all libraries. + * + * @return array + * + * @SuppressWarnings(PHPMD.Superglobals) + */ private function getLibraries() { return array_map( @@ -58,6 +74,11 @@ class Credits ); } + /** + * Extract version and dependencies from composer. + * + * @return array + */ private function extractFromComposer() { $local = TL_ROOT . '/composer/vendor/netzmacht/contao-leaflet-maps/composer.json'; diff --git a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php b/src/Netzmacht/Contao/Leaflet/ContaoAssets.php index 6bd7862..9d2a6a6 100644 --- a/src/Netzmacht/Contao/Leaflet/ContaoAssets.php +++ b/src/Netzmacht/Contao/Leaflet/ContaoAssets.php @@ -14,18 +14,23 @@ namespace Netzmacht\Contao\Leaflet; use Netzmacht\LeafletPHP\Assets; /** - * Class ContaoAssets + * Class ContaoAssets handles leaflet assets and integrate them into the Contao assets registry (Superglobals). + * * @package Netzmacht\Contao\Leaflet */ class ContaoAssets implements Assets { /** - * @var + * The map javascript. + * + * @var string */ private $map; /** * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function addJavascript($script, $type = self::TYPE_SOURCE) { @@ -48,6 +53,8 @@ class ContaoAssets implements Assets /** * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function addStylesheet($stylesheet, $type = self::TYPE_FILE) { diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Control.php b/src/Netzmacht/Contao/Leaflet/Dca/Control.php index b448ca8..03c7bfd 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Control.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Control.php @@ -11,26 +11,42 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\DevTools\ServiceContainerTrait; use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\Contao\Leaflet\Model\LayerModel; +/** + * Class Control is the helper for the tl_leaflet_control dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Control { use ServiceContainerTrait; /** + * The database connection. + * * @var \Database */ private $database; + /** + * Construct. + */ public function __construct() { $this->database = static::getService('database.connection'); } + /** + * Generate a row. + * + * @param array $row The data row. + * + * @return string + */ public function generateRow($row) { return sprintf( @@ -40,6 +56,11 @@ class Control ); } + /** + * Get layers for the layers control. + * + * @return array + */ public function getLayers() { $options = array(); @@ -54,6 +75,11 @@ class Control return $options; } + /** + * Get the zoom controls for the reference value of the loading control. + * + * @return array + */ public function getZoomControls() { $collection = ControlModel::findBy('type', 'zoom', array('order' => 'title')); @@ -61,6 +87,16 @@ class Control return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions(); } + /** + * Load layer relations. + * + * @param mixed $value The actual value. + * @param \DataContainer $dataContainer The data container driver. + * + * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function loadLayerRelations($value, $dataContainer) { $result = $this->database @@ -70,6 +106,14 @@ class Control return $result->fetchAllAssoc(); } + /** + * Save layer relations. + * + * @param $layers $layers The layer id values. + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return null + */ public function saveLayerRelations($layers, $dataContainer) { $new = deserialize($layers, true); diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Content.php b/src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php similarity index 74% rename from src/Netzmacht/Contao/Leaflet/Dca/Content.php rename to src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php index cac6e2f..7385f86 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Content.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/FrontendIntegration.php @@ -15,10 +15,11 @@ use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\Leaflet\Model\MapModel; /** - * Class Content + * Class Module is the helper for the tl_module dca. + * * @package Netzmacht\Contao\Leaflet\Dca */ -class Content +class FrontendIntegration { /** * Get all leaflet maps. @@ -32,20 +33,31 @@ class Content return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions(); } + /** + * Get edit map link wizard. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return string + * + * @SuppressWarnings(PHPMD.Superglobals) + */ public function getEditMapLink($dataContainer) { if ($dataContainer->value < 1) { return ''; } + $pattern = 'title="%s" style="padding-left: 3px" onclick="Backend.openModalIframe('; + $pattern .= '{\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"'; + return sprintf( '%s', 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=', $dataContainer->value, \RequestToken::get(), sprintf( - 'title="%s" style="padding-left: 3px" ' - . 'onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"', + $pattern, specialchars(sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)), specialchars( str_replace( @@ -57,7 +69,8 @@ class Content ), \Image::getHtml( 'alias.gif', - $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top"' + $GLOBALS['TL_LANG']['tl_content']['editalias'][0], + 'style="vertical-align:top"' ) ); } diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Layer.php b/src/Netzmacht/Contao/Leaflet/Dca/Layer.php index 818fc0a..c2047af 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Layer.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Layer.php @@ -11,22 +11,38 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\DevTools\ServiceContainerTrait; use Netzmacht\Contao\Leaflet\Model\LayerModel; +/** + * Class Layer is the helper class for the tl_leaflet_layer dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Layer { use ServiceContainerTrait; + /** + * Layers definition. + * + * @var array + */ private $layers; /** + * The database connection. + * * @var \Database */ private $database; + /** + * Construct. + * + * @SuppressWarnings(PHPMD.Superglobals) + */ public function __construct() { $this->layers = &$GLOBALS['LEAFLET_LAYERS']; @@ -36,6 +52,15 @@ class Layer } + /** + * Get variants of the tile provider. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return array + * + * @SuppressWarnings(PHPMD.Superglobals) + */ public function getVariants($dataContainer) { if ($dataContainer->activeRecord @@ -48,6 +73,16 @@ class Layer return array(); } + /** + * Generate a row. + * + * @param array $row The data row. + * @param string $label Current row label. + * + * @return string + * + * @SuppressWarnings(PHPMD.Superglobals) + */ public function generateRow($row, $label) { $alt = empty($GLOBALS['TL_LANG']['leaflet_layer'][$row['type']][0]) @@ -74,11 +109,16 @@ class Layer return $icon . ' ' . $label; } + /** + * Get all marker cluster layers. + * + * @return array + */ public function getMarkerClusterLayers() { $types = array_keys( array_filter( - $GLOBALS['LEAFLET_LAYERS'], + $this->layers, function ($item) { return !empty($item['markerCluster']); } @@ -89,7 +129,7 @@ class Layer $builder = OptionsBuilder::fromCollection( $collection, 'id', - function($row) { + function ($row) { return sprintf('%s [%s]', $row['title'], $row['type']); } ); @@ -97,7 +137,20 @@ class Layer return $builder->getOptions(); } - // Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next) + /** + * Get the paste buttons depending on the layer type. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * @param array $row The data row. + * @param string $table The table name. + * @param null $whatever Who knows what the purpose of this var is. + * @param array $children The child content. + * + * @return string + * + * @SuppressWarnings(PHPMD.Superglobals) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function getPasteButtons($dataContainer, $row, $table, $whatever, $children) { $pasteAfterUrl = \Controller::addToUrl( @@ -142,6 +195,18 @@ class Layer return $buffer; } + /** + * Generate the markers button. + * + * @param array $row Current row. + * @param string $href The button href. + * @param string $label The button label. + * @param string $title The button title. + * @param string $icon The button icon. + * @param string $attributes Optional attributes. + * + * @return string + */ public function generateMarkersButton($row, $href, $label, $title, $icon, $attributes) { if (empty($this->layers[$row['type']]['markers'])) { @@ -151,6 +216,18 @@ class Layer return $this->generateButton($row, $href, $label, $title, $icon, $attributes); } + /** + * Generate the vectors button. + * + * @param array $row Current row. + * @param string $href The button href. + * @param string $label The button label. + * @param string $title The button title. + * @param string $icon The button icon. + * @param string $attributes Optional attributes. + * + * @return string + */ public function generateVectorsButton($row, $href, $label, $title, $icon, $attributes) { if (empty($this->layers[$row['type']]['vectors'])) { @@ -160,6 +237,13 @@ class Layer return $this->generateButton($row, $href, $label, $title, $icon, $attributes); } + /** + * Get all layers except of the current layer. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return array + */ public function getLayers($dataContainer) { $collection = LayerModel::findBy('id !', $dataContainer->id); @@ -169,7 +253,14 @@ class Layer ->getOptions(); } - + /** + * Delete the relations when the layer is deleted. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * @param int $undoId The id of the undo entry. + * + * @return void + */ public function deleteRelations($dataContainer, $undoId) { if ($undoId) { @@ -212,12 +303,14 @@ class Layer } /** - * @param $row - * @param $href - * @param $label - * @param $title - * @param $icon - * @param $attributes + * Generate a button. + * + * @param array $row Current row. + * @param string $href The button href. + * @param string $label The button label. + * @param string $title The button title. + * @param string $icon The button icon. + * @param string $attributes Optional attributes. * * @return string */ diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php b/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php index e7dde28..9be0154 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Leaflet.php @@ -11,19 +11,23 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Mapper\MapMapper; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\Contao\Leaflet\Model\MapModel; use Netzmacht\LeafletPHP\Definition\Type\LatLng; +/** + * Class Leaflet is the base helper providing different methods. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Leaflet { /** * Validate a coordinate. * - * @param $value + * @param mixed $value The given value. * * @return mixed */ @@ -38,29 +42,44 @@ class Leaflet return $value; } - + /** + * Create the zoom range. + * + * @return array + */ public function getZoomLevels() { return range(1, 20); } - + /** + * Get the geocoder wizard. + * + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return string + */ public function getGeocoder($dataContainer) { - $template = new \BackendTemplate('be_leaflet_geocode'); + $template = new \BackendTemplate('be_leaflet_geocode'); $template->field = 'ctrl_' . $dataContainer->field; try { $latLng = LatLng::fromString($dataContainer->value); $template->marker = json_encode($latLng); - } catch(\Exception $e) { - + } catch (\Exception $e) { + // LatLng throws an exeption of value could not be created. Just let the value empty when. } return $template->parse(); } + /** + * Get all layers. + * + * @return array + */ public function getLayers() { $options = array(); diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Map.php b/src/Netzmacht/Contao/Leaflet/Dca/Map.php index 4cc7607..1751f4a 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Map.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Map.php @@ -11,23 +11,42 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\DevTools\ServiceContainerTrait; +/** + * Class Map is the helper class for the tl_leaflet_map dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Map { use ServiceContainerTrait; /** + * The database connection. + * * @var \Database */ private $database; + /** + * Construct. + */ public function __construct() { $this->database = static::getService('database.connection'); } + /** + * Load layer relations. + * + * @param mixed $value The actual value. + * @param \DataContainer $dataContainer The data container driver. + * + * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ public function loadLayerRelations($value, $dataContainer) { $result = $this->database @@ -37,6 +56,14 @@ class Map return $result->fetchEach('lid'); } + /** + * Save layer relations. + * + * @param mixed $layerId The layer id values. + * @param \DataContainer $dataContainer The dataContainer driver. + * + * @return null + */ public function saveLayerRelations($layerId, $dataContainer) { $new = deserialize($layerId, true); @@ -67,7 +94,8 @@ class Map $sorting += 128; } else { - if ($values[$layerId]['sorting'] <= ($sorting - 128) || $values[$layerId]['sorting'] >= ($sorting + 128)) { + if ($values[$layerId]['sorting'] <= ($sorting - 128) + || $values[$layerId]['sorting'] >= ($sorting + 128)) { $this->database ->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?') ->set(array('tstamp' => time(), 'sorting' => $sorting)) diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Marker.php b/src/Netzmacht/Contao/Leaflet/Dca/Marker.php index 6d0d440..6d666bb 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Marker.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Marker.php @@ -11,28 +11,44 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\Leaflet\Model\IconModel; +/** + * Class Marker is the dca helper class for the tl_leaflet_marker dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Marker { + /** + * Generate the row label. + * + * @param array $row Current data row. + * + * @return string + */ public function generateRow($row) { return $row['title']; } + /** + * Get all icons. + * + * @return array + */ public function getIcons() { $collection = IconModel::findAll(array('order' => 'title')); $builder = OptionsBuilder::fromCollection( - $collection, 'id', - function($model) { + $collection, + 'id', + function ($model) { return sprintf('%s [%s]', $model['title'], $model['type']); } ); return $builder->getOptions(); } - } diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Module.php b/src/Netzmacht/Contao/Leaflet/Dca/Module.php deleted file mode 100644 index ebb640d..0000000 --- a/src/Netzmacht/Contao/Leaflet/Dca/Module.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright 2014 netzmacht creative David Molineus - * @license LGPL 3.0 - * @filesource - * - */ - -namespace Netzmacht\Contao\Leaflet\Dca; - -use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; -use Netzmacht\Contao\Leaflet\Model\MapModel; - -/** - * Class Module - * @package Netzmacht\Contao\Leaflet\Dca - */ -class Module -{ - /** - * Get all leaflet maps. - * - * @return array - */ - public function getMaps() - { - $collection = MapModel::findAll(); - - return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions(); - } - - public function getEditMapLink($dataContainer) - { - if ($dataContainer->value < 1) { - return ''; - } - - return sprintf( - '%s', - 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=', - $dataContainer->value, - \RequestToken::get(), - sprintf( - 'title="%s" style="padding-left: 3px" ' - . 'onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%s\',\'url\':this.href});return false"', - specialchars(sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value)), - specialchars( - str_replace( - "'", - "\\'", - sprintf($GLOBALS['TL_LANG']['tl_content']['editalias'][1], $dataContainer->value) - ) - ) - ), - \Image::getHtml( - 'alias.gif', - $GLOBALS['TL_LANG']['tl_content']['editalias'][0], 'style="vertical-align:top"' - ) - ); - } -} diff --git a/src/Netzmacht/Contao/Leaflet/Dca/Vector.php b/src/Netzmacht/Contao/Leaflet/Dca/Vector.php index 6946d88..53dadf7 100644 --- a/src/Netzmacht/Contao/Leaflet/Dca/Vector.php +++ b/src/Netzmacht/Contao/Leaflet/Dca/Vector.php @@ -11,12 +11,23 @@ namespace Netzmacht\Contao\Leaflet\Dca; - use Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder; use Netzmacht\Contao\Leaflet\Model\StyleModel; +/** + * Helper class for the tl_leaflet_vector dca. + * + * @package Netzmacht\Contao\Leaflet\Dca + */ class Vector { + /** + * Generate the row label. + * + * @param array $row Current data row. + * + * @return string + */ public function generateRow($row) { return sprintf('%s [%s]', $row['title'], $row['type']); diff --git a/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php b/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php index a1c5017..96fb38d 100644 --- a/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php +++ b/src/Netzmacht/Contao/Leaflet/Definition/Style/FixedStyle.php @@ -11,12 +11,16 @@ namespace Netzmacht\Contao\Leaflet\Definition\Style; - use Netzmacht\Contao\Leaflet\Definition\Style; use Netzmacht\LeafletPHP\Definition\AbstractDefinition; use Netzmacht\LeafletPHP\Definition\OptionsTrait; use Netzmacht\LeafletPHP\Definition\Vector\Path; +/** + * Class FixedStyle is a style which simple has fixed definitions. + * + * @package Netzmacht\Contao\Leaflet\Definition\Style + */ class FixedStyle extends AbstractDefinition implements Style { use OptionsTrait; diff --git a/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php b/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php index 3dc8891..1ce2149 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php +++ b/src/Netzmacht/Contao/Leaflet/Event/BuildDefinitionEvent.php @@ -52,7 +52,7 @@ class BuildDefinitionEvent extends Event * @param \Model $model The definition model. * @param LatLngBounds $bounds Optional bounds where elements should be in. */ - public function __construct(Definition $definition = null, \Model $model, LatLngBounds $bounds = null) + public function __construct(Definition $definition, \Model $model, LatLngBounds $bounds = null) { $this->definition = $definition; $this->model = $model; diff --git a/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php b/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php index 586df49..3b32bfa 100644 --- a/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php +++ b/src/Netzmacht/Contao/Leaflet/Event/InitializeDefinitionMapperEvent.php @@ -15,7 +15,7 @@ use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Symfony\Component\EventDispatcher\Event; /** - * Class InitializeDefinitionMapperEvent + * Class InitializeDefinitionMapperEvent is emitted when the definition mapper is created. * * @package Netzmacht\Contao\Leaflet\Event */ @@ -24,6 +24,8 @@ class InitializeDefinitionMapperEvent extends Event const NAME = 'leaflet.boot.initialize-definition-mapper'; /** + * The definitino mapper. + * * @var DefinitionMapper */ private $definitionMapper; diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php b/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php index cad9c86..22db74f 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/DataController.php @@ -11,32 +11,53 @@ namespace Netzmacht\Contao\Leaflet\Frontend; - use Netzmacht\Contao\Leaflet\MapService; +/** + * The data controller handles ajax request for sub data. + * + * @package Netzmacht\Contao\Leaflet\Frontend + */ class DataController { /** + * The map service. + * * @var MapService */ private $mapService; /** + * The user input object. + * * @var \Input */ private $input; + /** + * Construct. + * + * @param MapService $mapService The map service. + * @param \Input $input The user input object. + */ public function __construct(MapService $mapService, \Input $input) { $this->mapService = $mapService; $this->input = $input; } + /** + * Execute the controller and create the data response. + * + * @return void + * + * @throws \Exception If anything went wrong. + */ public function execute() { - $format = $this->input->get('format') ?: 'geojson'; - $type = $this->input->get('type') ?: 'layer'; - $dataId = $this->input->get('id'); + $format = $this->getInput('format', 'geojson'); + $type = $this->getInput('type', 'layer'); + $dataId = $this->getInput('id'); try { list($data, $error) = $this->loadData($type, $dataId); @@ -55,8 +76,12 @@ class DataController } /** - * @param $format - * @param $data + * Enocode the data. + * + * @param string $format The requested format. + * @param mixed $data The given data. + * + * @return void */ public function encodeData($format, $data) { @@ -65,12 +90,17 @@ class DataController header('Content-Type: application/json'); echo json_encode($data, JSON_UNESCAPED_SLASHES); break; + + default: + // Blame the code sniffer. } } /** - * @param $type - * @param $dataId + * Load the data. + * + * @param string $type The data type. + * @param mixed $dataId The data id. * * @return array */ @@ -92,4 +122,17 @@ class DataController return array($data, $error); } + + /** + * Get an input value. + * + * @param string $name The input name. + * @param mixed $default Optional a default value if empty. + * + * @return string + */ + protected function getInput($name, $default = null) + { + return $this->input->get($name) ?: $default; + } } diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/HybridTrait.php b/src/Netzmacht/Contao/Leaflet/Frontend/HybridTrait.php new file mode 100644 index 0000000..a8cf191 --- /dev/null +++ b/src/Netzmacht/Contao/Leaflet/Frontend/HybridTrait.php @@ -0,0 +1,110 @@ + + * @copyright 2015 netzmacht creative David Molineus + * @license LGPL 3.0 + * @filesource + * + */ + +namespace Netzmacht\Contao\Leaflet\Frontend; + +use Netzmacht\Contao\Leaflet\MapService; +use Netzmacht\Contao\Leaflet\Model\MapModel; + +/** + * Class HybridTrait provides method required by the frontend module and content element the same time. + * + * @package Netzmacht\Contao\Leaflet\Frontend + */ +trait HybridTrait +{ + /** + * The map service. + * + * @var MapService + */ + private $mapService; + + /** + * Construct. + * + * @param \ContentModel $objElement Content element model. + * @param string $strColumn Layout column. + * + * @return void + */ + protected function construct($objElement, $strColumn = 'main') + { + parent::__construct($objElement, $strColumn); + + $this->mapService = static::getService('leaflet.map.service'); + } + + /** + * Do the frontend integration generation. + * + * @return string + */ + public function generate() + { + if (TL_MODE === 'BE') { + $model = MapModel::findByPK($this->leaflet_map); + + $template = new \BackendTemplate('be_wildcard'); + + if ($model) { + $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id; + + $template->wildcard = '### LEAFLET MAP ' . $model->title . ' ###'; + $template->title = $this->headline; + $template->id = $model->id; + $template->link = $model->title; + $template->href = $href; + } + + return $template->parse(); + } + + return parent::generate(); + } + + /** + * Do the frontend integration compiling. + * + * @return void + * + * @throws \Exception If something went wrong. + * + * @SuppressWarnings(PHPMD.Superglobals) + */ + protected function compile() + { + try { + $mapId = 'map_' . ($this->cssID[0] ?: ('ce_' . $this->id)); + $map = $this->mapService->getJavascript($this->leaflet_map, null, $mapId); + + $GLOBALS['TL_BODY'][] = ''; + + $this->Template->mapId = $mapId; + + $style = ''; + $height = deserialize($this->leaflet_height, true); + $width = deserialize($this->leaflet_width, true); + + if (!empty($width['value'])) { + $style .= 'width:' . $width['value'] . $width['unit'] . ';'; + } + + if (!empty($height['value'])) { + $style .= 'height:' . $height['value'] . $height['unit'] . ';'; + } + + $this->Template->mapStyle = $style; + } catch (\Exception $e) { + throw $e; + } + } +} diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php b/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php index d05b520..b52df58 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php @@ -12,14 +12,19 @@ namespace Netzmacht\Contao\Leaflet\Frontend; use ContentElement; +use Netzmacht\Contao\DevTools\ServiceContainerTrait; use Netzmacht\Contao\Leaflet\MapService; -use Netzmacht\Contao\Leaflet\Model\MapModel; /** + * The content element for the leaflet map. + * * @property int leaflet_map */ class MapElement extends \ContentElement { + use ServiceContainerTrait; + use HybridTrait; + /** * Template name. * @@ -28,78 +33,10 @@ class MapElement extends \ContentElement protected $strTemplate = 'ce_leaflet_map'; /** - * @var MapService - */ - private $mapService; - - /** - * Construct. - * - * @param \ContentModel $objElement Content element model. - * @param string $strColumn Layout column. + * {@inheritdoc} */ public function __construct($objElement, $strColumn = 'main') { - parent::__construct($objElement, $strColumn); - - $this->mapService = $GLOBALS['container']['leaflet.map.service']; - } - - public function generate() - { - if (TL_MODE === 'BE') { - $model = MapModel::findByPK($this->leaflet_map); - - $template = new \BackendTemplate('be_wildcard'); - - if ($model) { - $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id; - - $template->wildcard = '### LEAFLET MAP ' . $model->title . ' ###'; - $template->title = $this->headline; - $template->id = $model->id; - $template->link = $model->title; - $template->href = $href; - } - - return $template->parse(); - } - - return parent::generate(); - } - - /** - * Compile the content element. - * - * @return void - * - * @throws \Exception - */ - protected function compile() - { - try { - $mapId = 'map_' . ($this->cssID[0] ?: ('ce_' . $this->id)); - $map = $this->mapService->getJavascript($this->leaflet_map, null, $mapId); - - $GLOBALS['TL_BODY'][] = ''; - - $this->Template->mapId = $mapId; - - $style = ''; - $height = deserialize($this->leaflet_height, true); - $width = deserialize($this->leaflet_width, true); - - if (!empty($width['value'])) { - $style .= 'width:' . $width['value'] . $width['unit'] . ';'; - } - - if (!empty($height['value'])) { - $style .= 'height:' . $height['value'] . $height['unit'] . ';'; - } - - $this->Template->mapStyle = $style; - } catch(\Exception $e) { - throw $e; - } + $this->construct($objElement, $strColumn); } } diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php b/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php index 37b136d..92c7a35 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php @@ -11,12 +11,19 @@ namespace Netzmacht\Contao\Leaflet\Frontend; - +use Netzmacht\Contao\DevTools\ServiceContainerTrait; use Netzmacht\Contao\Leaflet\MapService; -use Netzmacht\Contao\Leaflet\Model\MapModel; +/** + * The frontend module for the Leaflet map. + * + * @package Netzmacht\Contao\Leaflet\Frontend + */ class MapModule extends \Module { + use ServiceContainerTrait; + use HybridTrait; + /** * Template name. * @@ -25,77 +32,10 @@ class MapModule extends \Module protected $strTemplate = 'mod_leaflet_map'; /** - * @var MapService - */ - private $mapService; - - /** - * Construct. - * - * @param \ModuleModel $objElement Module model. - * @param string $strColumn Layout column. + * {@inheritdoc} */ public function __construct($objElement, $strColumn = 'main') { - parent::__construct($objElement, $strColumn); - - $this->mapService = $GLOBALS['container']['leaflet.map.service']; - } - - public function generate() - { - if (TL_MODE === 'BE') { - $model = MapModel::findByPK($this->leaflet_map); - $template = new \BackendTemplate('be_wildcard'); - - if ($model) { - $href = 'contao/main.php?do=leaflet&table=tl_leaflet_map&act=edit&id=' . $model->id; - - $template->wildcard = '### LEAFLET MAP ' . $model->title . ' ###'; - $template->title = $this->headline; - $template->id = $model->id; - $template->link = $model->title; - $template->href = $href; - } - - return $template->parse(); - } - - return parent::generate(); - } - - /** - * Compile the content element. - * - * @return void - * - * @throws \Exception - */ - protected function compile() - { - try { - $mapId = 'map_' . ($this->cssID[0] ?: ('mod_' . $this->id)); - $map = $this->mapService->getJavascript($this->leaflet_map, null, $mapId); - - $GLOBALS['TL_BODY'][] = ''; - - $this->Template->mapId = $mapId; - - $style = ''; - $height = deserialize($this->leaflet_height, true); - $width = deserialize($this->leaflet_width, true); - - if (!empty($width['value'])) { - $style .= 'width:' . $width['value'] . $width['unit'] . ';'; - } - - if (!empty($height['value'])) { - $style .= 'height:' . $height['value'] . $height['unit'] . ';'; - } - - $this->Template->mapStyle = $style; - } catch(\Exception $e) { - throw $e; - } + $this->construct($objElement, $strColumn); } } diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php b/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php index c1ad386..1858c55 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/RequestUrl.php @@ -25,27 +25,27 @@ class RequestUrl /** * Create the request url. * - * @param int $id Object id. + * @param int $dataId The data object id. * @param string|null $type Object type. If empty it assumes a layer. * @param string|null $format Data format. If empty it assumes geojson. * * @return string */ - public static function create($id, $type = null, $format = null) + public static function create($dataId, $type = null, $format = null) { - return self::createBuilder($id, $type, $format)->getUrl(); + return self::createBuilder($dataId, $type, $format)->getUrl(); } /** * Create the request builder. * - * @param int $id Object id. + * @param int $dataId The data object id. * @param string|null $type Object type. If empty it assumes a layer. * @param string|null $format Data format. If empty it assumes geojson. * * @return UrlBuilder */ - public static function createBuilder($id, $type = null, $format = null) + public static function createBuilder($dataId, $type = null, $format = null) { $path = \Config::get('websitePath') . '/' . static::BASE; $builder = new UrlBuilder(); @@ -53,7 +53,7 @@ class RequestUrl ->setPath($path) ->setQueryParameter('type', $type ?: 'layer') ->setQueryParameter('format', $format ?: 'geojson') - ->setQueryParameter('id', $id); + ->setQueryParameter('id', $dataId); return $builder; } diff --git a/src/Netzmacht/Contao/Leaflet/MapService.php b/src/Netzmacht/Contao/Leaflet/MapService.php index 4dc76a9..3ba1f1f 100644 --- a/src/Netzmacht/Contao/Leaflet/MapService.php +++ b/src/Netzmacht/Contao/Leaflet/MapService.php @@ -44,6 +44,8 @@ class MapService private $leaflet; /** + * The event dispatcher. + * * @var EventDispatcher */ private $eventDispatcher; @@ -130,6 +132,8 @@ class MapService * @param LatLngBounds $bounds Filter features in the bounds. * * @return FeatureCollection + * + * @throws \InvalidArgumentException If a layer could not be found. */ public function getFeatureCollection($layerId, LatLngBounds $bounds = null) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php index 11d8e7c..8d796d3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractMapper.php @@ -24,7 +24,7 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; abstract class AbstractMapper implements Mapper { const VALUE_NOT_EMPTY = '__value_not_empty__'; - const VALUE_EMPTY = '__value_empty__'; + const VALUE_EMPTY = '__value_empty__'; /** * Class of the model being build. @@ -190,6 +190,8 @@ abstract class AbstractMapper implements Mapper * @param LatLngBounds $bounds Optional bounds where elements should be in. * * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function build( Definition $definition, @@ -224,12 +226,14 @@ abstract class AbstractMapper implements Mapper /** * Get construct arguments. * - * @param \Model $model The model. - * @param DefinitionMapper $mapper The definition mapper. - * @param LatLngBounds $bounds Optional bounds where elements should be in. + * @param \Model $model The model. + * @param DefinitionMapper $mapper The definition mapper. + * @param LatLngBounds $bounds Optional bounds where elements should be in. * @param string|null $elementId Optional element id. * * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function buildConstructArguments( \Model $model, @@ -301,6 +305,8 @@ abstract class AbstractMapper implements Mapper * @param array $options The options. * @param Definition $definition The definition being built. * @param \Model $model The model. + * + * @return void */ protected function applyOptions($options, $definition, $model) { @@ -312,8 +318,7 @@ abstract class AbstractMapper implements Mapper if (((bool) $model->$option) !== $default) { $definition->$setter($model->$mapping); } - } - elseif ($model->$mapping !== $default) { + } elseif ($model->$mapping !== $default) { $definition->$setter($model->$mapping); } } @@ -351,6 +356,8 @@ abstract class AbstractMapper implements Mapper * @param LatLngBounds $bounds Optional bounds where elements should be in. * * @return string + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function getClassName(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php index 0405066..30bca89 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/AbstractTypeMapper.php @@ -13,11 +13,23 @@ namespace Netzmacht\Contao\Leaflet\Mapper; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; - +/** + * Class AbstractTypeMapper is the base mapper for tables containing different types of definitins. + * + * @package Netzmacht\Contao\Leaflet\Mapper + */ abstract class AbstractTypeMapper extends AbstractMapper { + /** + * The definition type. + * + * @var string + */ protected static $type; + /** + * {@inheritdoc} + */ public function match($model, LatLngBounds $bounds = null) { return parent::match($model) && $model->type === static::$type; diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php index 74779fb..d750e40 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/AbstractControlMapper.php @@ -13,6 +13,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +/** + * Class AbstractControlMapper is the base mapper for the control model. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ class AbstractControlMapper extends AbstractTypeMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php index 40d899c..37d1254 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LayersControlMapper.php @@ -11,12 +11,16 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Class LayersControlMapper maps the control model to the layers control definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ class LayersControlMapper extends AbstractControlMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php index 9868b00..4da2b10 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Control/LoadingControlMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Control; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\ControlModel; use Netzmacht\LeafletPHP\Definition; @@ -20,6 +19,11 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Plugins\Loading\LoadingControl; use Netzmacht\LeafletPHP\Plugins\Loading\SpinJsLoadingControl; +/** + * Class LoadingControlMapper maps the control model to the loading control definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Control + */ class LoadingControlMapper extends AbstractControlMapper { /** @@ -77,7 +81,7 @@ class LoadingControlMapper extends AbstractControlMapper } } - if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl ) { + if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) { // Only assign if zoom control is activated and part of the map. $control = ControlModel::findOneBy( array('active=1', 'type=?', 'pid=?', 'id=?'), diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php index 4d5e760..8b26432 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/DefinitionMapper.php @@ -27,9 +27,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatche class DefinitionMapper { /** - * Registered builders. + * Lit of all registered mappers. * - * @var AbstractMapper[][] + * @var Mapper[][] */ private $builders = array(); @@ -41,6 +41,8 @@ class DefinitionMapper private $eventDispatcher; /** + * Cache of mapped definitions. + * * @var array */ private $mapped = array(); @@ -79,7 +81,9 @@ class DefinitionMapper * @param LatLngBounds $bounds Optional bounds where elements should be in. * @param string $elementId Optional element id. If none given the mapId or alias is used. * - * @return Definition + * @return Definition|null + * + * @throws \RuntimeException If model could not be mapped to a definition. */ public function handle($model, LatLngBounds $bounds = null, $elementId = null) { @@ -90,7 +94,7 @@ class DefinitionMapper } foreach ($this->builders as $builders) { - foreach($builders as $builder) { + foreach ($builders as $builder) { if ($builder->match($model)) { $definition = $builder->handle($model, $this, $bounds, $elementId); @@ -118,10 +122,12 @@ class DefinitionMapper /** * Build a model. * - * @param mixed $model The definition model. - * @param LatLngBounds $bounds Optional bounds where elements should be in. + * @param mixed $model The definition model. + * @param LatLngBounds $bounds Optional bounds where elements should be in. * - * @return FeatureCollection|Feature + * @return FeatureCollection|Feature|null + * + * @throws \RuntimeException If a model could not be mapped to the GeoJSON representation. */ public function handleGeoJson($model, LatLngBounds $bounds = null) { @@ -155,9 +161,14 @@ class DefinitionMapper } /** - * @param $model + * Get the hash of a model. + * + * @param mixed $model The definition model. + * @param string|null $elementId Optional defined extra element id. * * @return string + * + * @throws \RuntimeException If no hash was created. */ protected function getHash($model, $elementId) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php index 4e1171f..395007e 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/GeoJsonMapper.php @@ -11,16 +11,24 @@ namespace Netzmacht\Contao\Leaflet\Mapper; +use Netzmacht\LeafletPHP\Definition\GeoJson\GeoJsonFeature; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Interface GeoJsonMapper describes mappers which can convert their definition to a GeoJSON representation. + * + * @package Netzmacht\Contao\Leaflet\Mapper + */ interface GeoJsonMapper { /** - * @param \Model $model - * @param DefinitionMapper $mapper - * @param LatLngBounds $bounds + * Hanle the GeoJSON creation. * - * @return mixed + * @param \Model $model The model being mapped. + * @param DefinitionMapper $mapper The definition mapper. + * @param LatLngBounds $bounds The requested bounds. + * + * @return GeoJsonFeature|null */ public function handleGeoJson(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null); } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php index 92f494a..938dde1 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/AbstractLayerMapper.php @@ -13,6 +13,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +/** + * Class AbstractLayerMapper is the base mapper for the layer model. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ class AbstractLayerMapper extends AbstractTypeMapper { /** @@ -22,6 +27,9 @@ class AbstractLayerMapper extends AbstractTypeMapper */ protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\LayerModel'; + /** + * {@inheritdoc} + */ protected function initialize() { parent::initialize(); diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php index e37bc45..9c5eb6d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/GroupLayerMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Layer; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\LeafletPHP\Definition; @@ -19,6 +18,11 @@ use Netzmacht\LeafletPHP\Definition\Group\LayerGroup; use Netzmacht\LeafletPHP\Definition\Layer; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Class GroupLayerMapper maps the layer model to the group layer definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ class GroupLayerMapper extends AbstractLayerMapper { /** @@ -44,7 +48,7 @@ class GroupLayerMapper extends AbstractLayerMapper return 'Netzmacht\LeafletPHP\Definition\Group\FeatureGroup'; } - return parent::getClassName($model, $mapper, $bounds); // TODO: Change the autogenerated stub + return parent::getClassName($model, $mapper, $bounds); } /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php index 7c5d77b..9d2d4ea 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/MarkersLayerMapper.php @@ -24,6 +24,11 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\UI\Marker; use Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax; +/** + * Class MarkersLayerMapper maps the layer model to the markers definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper { /** @@ -81,11 +86,7 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper } /** - * @param \Model $model - * @param DefinitionMapper $mapper - * @param LatLngBounds $bounds - * - * @return mixed + * {@inheritdoc} */ public function handleGeoJson(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) { @@ -106,18 +107,14 @@ class MarkersLayerMapper extends AbstractLayerMapper implements GeoJsonMapper } /** - * @param \Model $model + * Load all layer markers. + * + * @param \Model $model The layer model. * * @return \Model\Collection|null */ protected function loadMarkerModels(\Model $model) { - $collection = MarkerModel::findBy( - array('active=1', 'pid=?'), - array($model->id), - array('order' => 'sorting') - ); - - return $collection; + return MarkerModel::findActiveBy('pid', $model->id, array('order' => 'sorting')); } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php index 1c80d77..0058448 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ProviderLayerMapper.php @@ -15,6 +15,11 @@ use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Class ProviderLayerMapper maps the layer model to the tile provider definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ class ProviderLayerMapper extends AbstractLayerMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php index 711f947..0b5658f 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/ReferenceLayerMapper.php @@ -16,7 +16,7 @@ use Netzmacht\Contao\Leaflet\Model\LayerModel; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; /** - * Class ReferenceLayerMapper maps an reference layer to another + * Class ReferenceLayerMapper maps an reference layer to another layer. * * @package Netzmacht\Contao\Leaflet\Mapper\Layer */ diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php index ebb1666..7247701 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Layer/VectorsLayerMapper.php @@ -26,6 +26,11 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector; use Netzmacht\LeafletPHP\Plugins\Ajax\GeoJsonAjax; +/** + * Class VectorsLayerMapper maps the layer model for the Vectors layer definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Layer + */ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper { /** @@ -87,11 +92,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper } /** - * @param \Model $model - * @param DefinitionMapper $mapper - * @param LatLngBounds $bounds - * - * @return mixed + * {@inheritdoc} */ public function handleGeoJson(\Model $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) { @@ -114,19 +115,14 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper } /** - * @param \Model $model + * Load vector models. + * + * @param \Model $model The layer model. * * @return \Model\Collection|null */ protected function loadVectorModels(\Model $model) { - $collection = VectorModel::findBy( - array('active=1', 'pid=?'), - array($model->id), - array('order' => 'sorting') - ); - - return $collection; + return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting')); } } - diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php index 6876367..4da06bb 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/MapMapper.php @@ -20,7 +20,11 @@ use Netzmacht\LeafletPHP\Definition\Layer; use Netzmacht\LeafletPHP\Definition\Map; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; - +/** + * Class MapMapper maps the database map model to the leaflet definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper + */ class MapMapper extends AbstractMapper { /** @@ -38,7 +42,7 @@ class MapMapper extends AbstractMapper protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Map'; /** - * @inheritdoc + * {@inheritdoc} */ protected function initialize() { @@ -51,7 +55,7 @@ class MapMapper extends AbstractMapper } /** - * @inheritdoc + * {@inheritdoc} */ protected function build(Definition $map, \Model $model, DefinitionMapper $builder, LatLngBounds $bounds = null) { @@ -63,7 +67,7 @@ class MapMapper extends AbstractMapper } /** - * @inheritdoc + * {@inheritdoc} */ protected function buildConstructArguments( \Model $model, @@ -99,6 +103,8 @@ class MapMapper extends AbstractMapper * @param MapModel $model The map model. * @param DefinitionMapper $mapper The definition mapper. * @param LatLngBounds $bounds Optional bounds. + * + * @return void */ private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) { @@ -124,6 +130,8 @@ class MapMapper extends AbstractMapper * @param MapModel $model The map model. * @param DefinitionMapper $mapper Definition mapper. * @param LatLngBounds $bounds Optional bounds. + * + * @return void */ private function buildLayers(Map $map, MapModel $model, DefinitionMapper $mapper, LatLngBounds $bounds = null) { diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php index 5bcd748..393b317 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Mapper.php @@ -14,12 +14,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Interface Mapper describes the Mapper which translates a given configuration to the Leaflet definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper + */ interface Mapper { /** * Map model to the definition. * - * @param \Model|mixed $model The model being built. Usually a contao model. but can be anything + * @param \Model|mixed $model The model being built. Usually a contao model, but can be anything. * @param DefinitionMapper $mapper The definition builder. * @param LatLngBounds $bounds Optional bounds where elements should be in. * @param string $elementId Optional element id. diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php index 7bf189b..a3b5187 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Style/AbstractStyleMapper.php @@ -13,6 +13,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Style; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +/** + * Class AbstractStyleMapper is the base mapper for the style model. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Style + */ abstract class AbstractStyleMapper extends AbstractTypeMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php index ab71a23..03e1245 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Style/FixedStyleMapper.php @@ -13,6 +13,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Style; use Netzmacht\LeafletPHP\Definition; +/** + * Class FixedStyleMapper maps the fixed style to the corresponding definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Style + */ class FixedStyleMapper extends AbstractStyleMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php index 18d6837..373a477 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Type/AbstractIconMapper.php @@ -11,9 +11,13 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type; - use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; +/** + * Class AbstractIconMapper is the base mapper for the icon model. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Type + */ class AbstractIconMapper extends AbstractTypeMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php index 4e02f81..5c038c8 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Type/DivIconMapper.php @@ -11,12 +11,16 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\DivIcon; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Class DivIconMapper maps the icon model to the div icon definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Type + */ class DivIconMapper extends AbstractIconMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php index b0e6d19..eeac264 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Type/ImageIconMapper.php @@ -11,13 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Type; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\IconModel; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; +/** + * Class ImageIconMapper maps the icon model to the image icon definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Type + */ class ImageIconMapper extends AbstractIconMapper { /** @@ -74,7 +78,7 @@ class ImageIconMapper extends AbstractIconMapper /** * Add icon image. * - * @param ImageIcon $definition The icon definition. + * @param ImageIcon $definition The icon definition. * @param IconModel $model The model. * * @return void @@ -116,7 +120,7 @@ class ImageIconMapper extends AbstractIconMapper /** * Add shadow if defined. * - * @param ImageIcon $definition The icon definition. + * @param ImageIcon $definition The icon definition. * @param IconModel $model The model. * * @return void diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php index bc68917..7a68981 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/UI/MarkerMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\UI; - use Netzmacht\Contao\Leaflet\Mapper\AbstractMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\Contao\Leaflet\Model\IconModel; @@ -20,6 +19,11 @@ use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\UI\Marker; +/** + * Class MarkerMapper maps the marker model to the marker definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\UI + */ class MarkerMapper extends AbstractMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php index ce4201b..dbb5766 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/AbstractVectorMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Definition\Style; use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper; use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; @@ -21,6 +20,11 @@ use Netzmacht\LeafletPHP\Definition\HasPopup; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\Path; +/** + * Class AbstractVectorMapper is the base class for the vector model definition mapping. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class AbstractVectorMapper extends AbstractTypeMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php index 16ea330..926c92e 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMapper.php @@ -11,13 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\Circle; +/** + * Class CircleMapper maps the database model to the circle definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class CircleMapper extends AbstractVectorMapper { /** @@ -34,6 +38,9 @@ class CircleMapper extends AbstractVectorMapper */ protected static $type = 'circle'; + /** + * {@inheritdoc} + */ protected function initialize() { parent::initialize(); @@ -41,6 +48,9 @@ class CircleMapper extends AbstractVectorMapper $this->addOption('radius'); } + /** + * {@inheritdoc} + */ protected function build( Definition $definition, \Model $model, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php index 52f39ea..d7979de 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/CircleMarkerMapper.php @@ -11,13 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\Circle; +/** + * Class CircleMarkerMapper maps the database model to the circle marker definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class CircleMarkerMapper extends CircleMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php index 33f3458..e03e6dd 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolygonMapper.php @@ -11,13 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\MultiPolygon; +/** + * Class MultiPolygonMapper maps the multi polygon database model to its definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class MultiPolygonMapper extends MultiPolylineMapper { /** @@ -34,6 +38,9 @@ class MultiPolygonMapper extends MultiPolylineMapper */ protected static $type = 'multiPolygon'; + /** + * {@inheritdoc} + */ protected function build( Definition $definition, \Model $model, @@ -43,18 +50,7 @@ class MultiPolygonMapper extends MultiPolylineMapper parent::build($definition, $model, $builder, $bounds); if ($definition instanceof MultiPolygon) { - $latLngs = array(); - - foreach (deserialize($model->multiData, true) as $data) { - $latLngs[] = array_map( - function ($row) { - return LatLng::fromString($row); - }, - explode("\n", $data) - ); - } - - $definition->setLatLngs($latLngs); + $this->createLatLngs($definition, $model); } } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php index 98ac2a0..9bf143d 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/MultiPolylineMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; @@ -19,6 +18,11 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\MultiPolyline; use Netzmacht\LeafletPHP\Definition\Vector\Polyline; +/** + * Class MultiPolylineMapper maps the databse model it the multi polyline definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class MultiPolylineMapper extends AbstractVectorMapper { /** @@ -35,7 +39,9 @@ class MultiPolylineMapper extends AbstractVectorMapper */ protected static $type = 'multiPolyline'; - + /** + * {@inheritdoc} + */ protected function build( Definition $definition, \Model $model, @@ -45,18 +51,31 @@ class MultiPolylineMapper extends AbstractVectorMapper parent::build($definition, $model, $builder, $bounds); if ($definition instanceof MultiPolyline) { - $latLngs = array(); - - foreach (deserialize($model->multiData, true) as $data) { - $latLngs[] = array_map( - function ($row) { - return LatLng::fromString($row); - }, - explode("\n", $data) - ); - } - - $definition->setLatLngs($latLngs); + $this->createLatLngs($definition, $model); } } + + /** + * Create lat lngs for the definition. + * + * @param MultiPolyline $definition The multi polyline. + * @param \Model $model The definition model. + * + * @return void + */ + protected function createLatLngs(MultiPolyline $definition, \Model $model) + { + $latLngs = array(); + + foreach (deserialize($model->multiData, true) as $data) { + $latLngs[] = array_map( + function ($row) { + return LatLng::fromString($row); + }, + explode("\n", $data) + ); + } + + $definition->setLatLngs($latLngs); + } } diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php index fe53233..15e972e 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolygonMapper.php @@ -11,6 +11,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; +/** + * Class PolygonMapper maps the database model to the polygon definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class PolygonMapper extends PolylineMapper { /** diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php index 766bef8..f8d70e3 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/PolylineMapper.php @@ -11,13 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\Polyline; +/** + * Class PolylineMapper maps the database model to the polyline definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class PolylineMapper extends AbstractVectorMapper { /** @@ -34,7 +38,9 @@ class PolylineMapper extends AbstractVectorMapper */ protected static $type = 'polyline'; - + /** + * {@inheritdoc} + */ protected function build( Definition $definition, \Model $model, diff --git a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php index 59fca69..2b9b120 100644 --- a/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php +++ b/src/Netzmacht/Contao/Leaflet/Mapper/Vector/RectangleMapper.php @@ -11,7 +11,6 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector; - use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper; use Netzmacht\LeafletPHP\Definition; use Netzmacht\LeafletPHP\Definition\Type\LatLng; @@ -19,6 +18,11 @@ use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds; use Netzmacht\LeafletPHP\Definition\Vector\Circle; use Netzmacht\LeafletPHP\Definition\Vector\Rectangle; +/** + * Class RectangleMapper maps a database model to its rectangle vector definition. + * + * @package Netzmacht\Contao\Leaflet\Mapper\Vector + */ class RectangleMapper extends AbstractVectorMapper { /** @@ -35,11 +39,9 @@ class RectangleMapper extends AbstractVectorMapper */ protected static $type = 'rectangle'; - protected function initialize() - { - parent::initialize(); - } - + /** + * {@inheritdoc} + */ protected function buildConstructArguments( \Model $model, DefinitionMapper $mapper, @@ -47,7 +49,7 @@ class RectangleMapper extends AbstractVectorMapper $elementId = null ) { $latLngs = array_map( - function($latLng) { + function ($latLng) { return LatLng::fromString($latLng); }, deserialize($model->bounds, true) diff --git a/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php b/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php index 81c37bf..d3814f0 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/AbstractActiveModel.php @@ -11,13 +11,18 @@ namespace Netzmacht\Contao\Leaflet\Model; - +/** + * Class AbstractActiveModel is the base model for models with an active field. + * + * @package Netzmacht\Contao\Leaflet\Model + */ abstract class AbstractActiveModel extends \Model { /** + * Find an active model by its model id. * - * @param int $modelId - * @param array $options + * @param int $modelId The model id. + * @param array $options The query options. * * @return \Model|null */ @@ -27,18 +32,33 @@ abstract class AbstractActiveModel extends \Model } /** + * Find active models by a defined column. * - * @param int $value - * @param array $options + * @param string|array $column The query columns. + * @param mixed $value The column value. + * @param array $options The options. * * @return \Model|null */ public static function findActiveBy($column, $value, $options = array()) { - return static::findBy('active=1 AND ' . $column, $value, $options); + if (is_array($column)) { + $column[] = 'active=1'; + } else { + $column = 'active=1 AND ' . $column; + } + + return static::findBy($column, $value, $options); } - public static function findActivated($options = array()) + /** + * Find collection activated models. + * + * @param array $options The query options. + * + * @return \Model\Collection|null + */ + public static function findActives($options = array()) { return static::findBy('active', '1', $options); } diff --git a/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php b/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php index e6d5597..d968f03 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/ControlModel.php @@ -11,33 +11,70 @@ namespace Netzmacht\Contao\Leaflet\Model; +use Model\Collection; + +/** + * Class ControlModel for the tl_leaflet_vector table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class ControlModel extends AbstractActiveModel { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_control'; /** - * @return \Model\Collection + * Find all related layers. + * + * @return Collection|null */ public function findLayers() { - $query = 'SELECT l.*, c.mode as controlMode FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_control_layer c ON l.id = c.lid WHERE c.cid=?'; + $query = <<prepare($query) ->execute($this->id); - return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer'); + if ($result->numRows < 1) { + return null; + } + + return Collection::createFromDbResult($result, 'tl_leaflet_layer'); } /** - * @return \Model\Collection + * Find active layers. + * + * @return Collection|null */ public function findActiveLayers() { - $query = 'SELECT l.*, c.mode as controlMode FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_control_layer c ON l.id = c.lid WHERE c.cid=? AND l.active=1'; + $query = <<prepare($query) ->execute($this->id); - return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer'); + if ($result->numRows < 1) { + return null; + } + + return Collection::createFromDbResult($result, 'tl_leaflet_layer'); } } diff --git a/src/Netzmacht/Contao/Leaflet/Model/IconModel.php b/src/Netzmacht/Contao/Leaflet/Model/IconModel.php index 6c725d0..ce2164e 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/IconModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/IconModel.php @@ -11,8 +11,9 @@ namespace Netzmacht\Contao\Leaflet\Model; - /** + * IconModel class for the tl_leaflet_icon table. + * * @property mixed|null iconImage * @property mixed|null iconAnchor * @property mixed|null popupAnchor @@ -23,5 +24,10 @@ namespace Netzmacht\Contao\Leaflet\Model; */ class IconModel extends AbstractActiveModel { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_icon'; } diff --git a/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php b/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php index 4daa4da..66f5e9f 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/LayerModel.php @@ -11,11 +11,30 @@ namespace Netzmacht\Contao\Leaflet\Model; +use Model\Collection; +/** + * Class LayerModel for the tl_leaflet_layer table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class LayerModel extends AbstractActiveModel { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_layer'; + /** + * Find multiple layers by given type. + * + * @param array $types List of layer types. + * @param array $options Query options. + * + * @return Collection|null + */ public static function findMultipleByTypes(array $types, $options = array()) { if (empty($types)) { @@ -29,7 +48,8 @@ class LayerModel extends AbstractActiveModel ) ); - $options['value'] = $types; + $options['value'] = $types; + $options['return'] = 'Collection'; return static::find($options); } diff --git a/src/Netzmacht/Contao/Leaflet/Model/MapModel.php b/src/Netzmacht/Contao/Leaflet/Model/MapModel.php index 1d15e91..175c794 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/MapModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/MapModel.php @@ -11,13 +11,26 @@ namespace Netzmacht\Contao\Leaflet\Model; +use Model\Collection; +/** + * Class MapModel for the tl_leaflet_map table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class MapModel extends \Model { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_map'; /** - * @return \Model\Collection + * Find all related layers. + * + * @return Collection|null */ public function findLayers() { @@ -26,19 +39,34 @@ class MapModel extends \Model ->prepare($query) ->execute($this->id); - return \Model\Collection::createFromDbResult($result, 'tl_leaflet_layer'); + if ($result->numRows < 1) { + return null; + } + + return Collection::createFromDbResult($result, 'tl_leaflet_layer'); } /** - * @return \Model\Collection + * Find all active layers. + * + * @return Collection|null */ public function findActiveLayers() { - $query = 'SELECT l.* FROM tl_leaflet_layer l LEFT JOIN tl_leaflet_map_layer m ON l.id = m.lid WHERE m.mid=? AND l.active=1'; - $result = \Database::getInstance() - ->prepare($query) - ->execute($this->id); + $query = <<prepare($query)->execute($this->id); + + if ($result->numRows) { + return Collection::createFromDbResult($result, 'tl_leaflet_layer'); + } + + return null; } } diff --git a/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php b/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php index c17bb72..706e8c1 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/MarkerModel.php @@ -11,9 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Model; - +/** + * Class MarkerModel for the tl_leaflet_marker table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class MarkerModel extends AbstractActiveModel { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_marker'; - } diff --git a/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php b/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php index 20e33c0..907d7fa 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/StyleModel.php @@ -11,8 +11,17 @@ namespace Netzmacht\Contao\Leaflet\Model; - +/** + * Class StyleModel for the tl_leaflet_style table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class StyleModel extends AbstractActiveModel { + /** + * Model table. + * + * @var string + */ protected static $strTable = 'tl_leaflet_style'; } diff --git a/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php b/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php index 816f7c1..d078849 100644 --- a/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php +++ b/src/Netzmacht/Contao/Leaflet/Model/VectorModel.php @@ -11,7 +11,11 @@ namespace Netzmacht\Contao\Leaflet\Model; - +/** + * Class VectorModel for the tl_leaflet_vector table. + * + * @package Netzmacht\Contao\Leaflet\Model + */ class VectorModel extends AbstractActiveModel { /** diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php index 449b5e4..16ef03e 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/BootSubscriber.php @@ -23,7 +23,7 @@ use Netzmacht\LeafletPHP\Definition\Type\ImageIcon; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * Class BootSubscriber + * Class BootSubscriber provides handlers for leaflet boot process. * * @package Netzmacht\Contao\Leaflet\Subscriber */ @@ -111,6 +111,8 @@ class BootSubscriber implements EventSubscriberInterface * Load Contao leaflet assets. * * @return void + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function loadAssets() { @@ -123,7 +125,9 @@ class BootSubscriber implements EventSubscriberInterface /** * Load icons. * - * @throws \Netzmacht\Javascript\Exception\EncodeValueFailed + * @return void + * + * @SuppressWarnings(PHPMD.Superglobals) */ public function loadIcons() { @@ -153,7 +157,9 @@ class BootSubscriber implements EventSubscriberInterface $file->write($buffer); $file->close(); + // @codingStandardsIgnoreStart // TODO: Cache it. + // codingStandardsIgnoreEnd $GLOBALS['TL_JAVASCRIPT'][] = 'assets/leaflet/js/icons.js' . (\Config::get('debugMode') ? '' : '|static' diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php index 0d8bc9b..9dbde17 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/EncoderSubscriber.php @@ -77,6 +77,13 @@ class EncoderSubscriber implements EventSubscriberInterface } } + /** + * Force that icons are encoded as reference to the ContaoLeaflet icon registry. + * + * @param EncodeValueEvent $event The subscribed event. + * + * @return void + */ public function encodeIcons(EncodeValueEvent $event) { $value = $event->getValue(); diff --git a/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php b/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php index c8c0436..34ee522 100644 --- a/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php +++ b/src/Netzmacht/Contao/Leaflet/Subscriber/HashSubscriber.php @@ -11,10 +11,14 @@ namespace Netzmacht\Contao\Leaflet\Subscriber; - use Netzmacht\Contao\Leaflet\Event\GetHashEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +/** + * Class HashSubscriber creates hashes for models and for data which does not have a hash created by other subscribers. + * + * @package Netzmacht\Contao\Leaflet\Subscriber + */ class HashSubscriber implements EventSubscriberInterface { /** @@ -33,7 +37,9 @@ class HashSubscriber implements EventSubscriberInterface /** * Get hash for a model object. * - * @param GetHashEvent $event + * @param GetHashEvent $event The subscribed event. + * + * @return void */ public function getModelHash(GetHashEvent $event) { @@ -47,7 +53,9 @@ class HashSubscriber implements EventSubscriberInterface /** * Get hash fallback if no hash was created so far. * - * @param GetHashEvent $event + * @param GetHashEvent $event The subscribed event. + * + * @return void */ public function getFallback(GetHashEvent $event) {