/**
  * Build the marker.
  *
  * @param Item   $item     The metamodel item.
  * @param string $parentId Id of the parent layer.
  *
  * @return Marker
  */
 protected function buildMarker(Item $item, $parentId)
 {
     $metaModel = $item->getMetaModel();
     $coordinates = $this->getCoordinates($item);
     if (!$coordinates) {
         return null;
     }
     $settings = $this->getRenderSettings($metaModel);
     $icon = $this->getIcon($item->get('id'));
     $popup = $this->getPopupContent($item, $settings);
     $identifier = sprintf('%s_%s_%s_marker', $parentId, $metaModel->getTableName(), $item->get('id'));
     $marker = new Marker($identifier, $coordinates);
     if ($this->model->options) {
         $marker->setOptions((array) json_decode($this->model->options, true));
     }
     if ($icon) {
         $marker->setIcon($icon);
     }
     if ($popup) {
         $marker->setPopupContent($popup);
     }
     // @codingStandardsIgnoreStart
     // TODO: Attributes mapping
     // @codingStandardsIgnoreEnd
     return $marker;
 }
Exemplo n.º 2
0
 /**
  * Remove invariant attributes from the render setting.
  *
  * This is done by cloning the input collection of render settings and removing any invariant attribute.
  *
  * @param IItem       $nativeItem    The native item.
  *
  * @param ICollection $renderSetting The render setting to be used.
  *
  * @return ICollection
  */
 protected static function removeInvariantAttributes(IItem $nativeItem, ICollection $renderSetting)
 {
     $model = $nativeItem->getMetaModel();
     if ($model->hasVariants() && !$nativeItem->isVariantBase()) {
         // Create a clone to have a separate copy of the object as we are going to manipulate it here.
         $renderSetting = clone $renderSetting;
         // Loop over all attributes and remove those from rendering that are not desired.
         foreach (array_keys($model->getInVariantAttributes()) as $strAttrName) {
             $renderSetting->setSetting($strAttrName, null);
         }
     }
     return $renderSetting;
 }
 /**
  * Get a MetaModel attribute by a column name of the FeatureModel which contains the id.
  *
  * @param string $column The name of the attribute id.
  * @param Item   $item   The metamodel item.
  *
  * @return Attribute
  */
 protected function getAttribute($column, Item $item)
 {
     return $item->getMetaModel()->getAttributeById($this->model->{$column});
 }
 /**
  * Apply the popup.
  *
  * @param Item  $item       The MetaModel item.
  * @param mixed $definition The definition.
  *
  * @return void
  */
 protected function applyPopup(Item $item, $definition)
 {
     if ($definition instanceof HasPopup) {
         $settings = $this->getRenderSettings($item->getMetaModel());
         $popup = $this->getPopupContent($item, $settings);
         if ($popup) {
             $definition->bindPopup($popup);
         }
     }
 }