/**
  * Create the request url.
  *
  * It combines the params and creates an hash for it.
  *
  * @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.
  * @param Filter      $filter Optional filter.
  *
  * @return RequestUrl
  */
 public static function create($dataId, $type = null, $format = null, Filter $filter = null)
 {
     $params = array('for' => static::$for, 'type' => $type != 'layer' ? $type : null, 'id' => $dataId, 'format' => $format != 'geojson' ? $format : null);
     $hash = base64_encode(implode(',', $params));
     $query = 'leaflet=' . $hash;
     if ($filter) {
         $query .= '&f=' . $filter->getName() . '&v=' . $filter->toRequest();
     }
     $url = \Config::get('websitePath') . '/' . \Frontend::addToUrl($query, false);
     return new static($url, $hash, $filter);
 }
 /**
  * Find by a filter.
  *
  * @param int    $pid    The parent id.
  * @param Filter $filter The filter.
  *
  * @return \Model\Collection|null
  */
 public static function findByFilter($pid, Filter $filter = null)
 {
     if (!$filter) {
         return static::findActiveBy('pid', $pid, array('order' => 'sorting'));
     }
     switch ($filter->getName()) {
         case 'bbox':
             return static::findByBBoxFilter($pid, $filter);
         default:
             return null;
     }
 }