/** * {@inheritdoc} * @SuppressWarnings(PHPMD.Superglobals) */ protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null) { parent::build($definition, $model, $mapper, $filter, $parent); /** @var MarkerClusterGroup $definition */ if ($model->iconCreateFunction) { $definition->setIconCreateFunction(new Expression($model->iconCreateFunction)); } if ($model->polygonOptions) { $definition->setPolygonOptions((array) json_decode($model->polygonOptions, true)); } if (!$model->disableDefaultStyle) { $GLOBALS['TL_CSS'][] = 'assets/leaflet/libs/leaflet-markercluster/MarkerCluster.Default.css||static'; } $collection = LayerModel::findBy(array('pid=?', 'active=1'), array($model->id), array('order' => 'sorting')); if ($collection) { foreach ($collection as $layerModel) { $layer = $mapper->handle($layerModel); if ($layer instanceof Layer) { $definition->addLayer($layer); if ($layer instanceof OmnivoreLayer) { $callback = new AnonymousFunction(); $callback->addLine('layers.' . $definition->getId() . '.addLayers(this.getLayers())'); $layer->on('ready', $callback); } } } } }
/** * Get all layers. * * @return array */ public function getLayers() { $options = array(); $collection = LayerModel::findBy('pid', '0', array('order' => 'title')); if ($collection) { foreach ($collection as $model) { $options[$model->id] = $model->title; } } return $options; }
/** * {@inheritdoc} */ protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null) { if (!$definition instanceof LayerGroup) { return; } $collection = LayerModel::findBy(array('pid=?', 'active=1'), array($model->id), array('order' => 'sorting')); if ($collection) { foreach ($collection as $layerModel) { $layer = $mapper->handle($layerModel); if ($layer instanceof Layer) { $definition->addLayer($layer); } } } }
/** * 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); return OptionsBuilder::fromCollection($collection, 'id', 'title')->asTree()->getOptions(); }