Code style.

This commit is contained in:
David Molineus
2015-01-22 13:34:22 +01:00
parent 178da21895
commit 62e2b02732
9 changed files with 35 additions and 15 deletions

View File

@@ -21,8 +21,10 @@ class FrontendApi extends \Frontend
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
// @codingStandardsIgnoreStart
public function replaceInsertTags($strBuffer, $blnCache = true) public function replaceInsertTags($strBuffer, $blnCache = true)
{ {
return parent::replaceInsertTags($strBuffer, $blnCache); return parent::replaceInsertTags($strBuffer, $blnCache);
} }
// @codingStandardsIgnoreEnd
} }

View File

@@ -43,7 +43,7 @@ class ValueFilter
* The idea behind this extra method is that we just have to change one place if anything else than the * The idea behind this extra method is that we just have to change one place if anything else than the
* insert tags has to be replaced. * insert tags has to be replaced.
* *
* @param string $value The given value * @param string $value The given value.
* *
* @return string * @return string
*/ */

View File

@@ -41,7 +41,7 @@ abstract class AbstractMapper implements Mapper
protected static $definitionClass = null; protected static $definitionClass = null;
/** /**
* Options builder * Options builder.
* *
* @var OptionsBuilder * @var OptionsBuilder
*/ */

View File

@@ -165,6 +165,7 @@ class DefinitionMapper
* @param mixed $model The data model. * @param mixed $model The data model.
* *
* @return Mapper * @return Mapper
* @throws \RuntimeException If the mapper could not be found.
*/ */
private function getMapper($model) private function getMapper($model)
{ {
@@ -178,7 +179,7 @@ class DefinitionMapper
throw new \RuntimeException( throw new \RuntimeException(
sprintf( sprintf(
'Could not build model "". No matching mappers found.', 'Could not build model "%s". No matching mappers found.',
$this->hash($model) $this->hash($model)
) )
); );

View File

@@ -102,7 +102,10 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
) { ) {
if ($definition instanceof GeoJson) { if ($definition instanceof GeoJson) {
$collection = $this->loadVectorModels($model); $collection = $this->loadVectorModels($model);
$definition->setOption('affectBounds', (bool) $model->affectBounds);
if ($model->affectBounds) {
$definition->setOption('affectBounds', true);
}
if ($collection) { if ($collection) {
foreach ($collection as $item) { foreach ($collection as $item) {
@@ -120,13 +123,7 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
} }
} }
if ($model->pointToLayer) { $this->addCallbacks($definition, $model);
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
if ($model->onEachFeature) {
$definition->setOnEachFeature(new Expression($model->onEachFeature));
}
} }
} }
@@ -170,4 +167,23 @@ class VectorsLayerMapper extends AbstractLayerMapper implements GeoJsonMapper
{ {
return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting')); return VectorModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
} }
/**
* Add javascript callbacks.
*
* @param GeoJson $definition The definition.
* @param \Model $model The database model.
*
* @return void
*/
protected function addCallbacks(GeoJson $definition, \Model $model)
{
if ($model->pointToLayer) {
$definition->setPointToLayer(new Expression($model->pointToLayer));
}
if ($model->onEachFeature) {
$definition->setOnEachFeature(new Expression($model->onEachFeature));
}
}
} }

View File

@@ -14,7 +14,7 @@ namespace Netzmacht\Contao\Leaflet;
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter; use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
/** /**
* Class ServiceContainer * Class ServiceContainer provides the services which are available for Contao leaflet.
* *
* @package Netzmacht\Contao\Leaflet * @package Netzmacht\Contao\Leaflet
*/ */

View File

@@ -22,6 +22,7 @@ trait ServiceContainerTrait
* Get the service container. * Get the service container.
* *
* @return ServiceContainer * @return ServiceContainer
* @SuppressWarnings(PHPMD.Superglobals)
*/ */
protected function getServiceContainer() protected function getServiceContainer()
{ {

View File

@@ -46,7 +46,7 @@ class HashSubscriber implements EventSubscriberInterface
$data = $event->getData(); $data = $event->getData();
if ($data instanceof \Model) { if ($data instanceof \Model) {
$event->setHash($data->getTable() . '.' . $data->{$data->getPk()}); $event->setHash($data->getTable() . '::' . $data->{$data->getPk()});
} }
} }