public function retrieve()
 {
     if ($this->site == null) {
         $sites = $this->getSites(AppDebug::getRequest());
         $this->site = reset($sites);
     }
     return parent::retrieve();
 }
 /**
  * @param $mapType
  * @param array $params
  * - map:{html_id, type, zoom }
  * - controls: []
  * - point: {title, title_style: (twirl#pinkStretchyIcon), latitude, longitude}
  * - polygon: [points: {}]
  * @return \Brother\MapBundle\Model\Map\YMap
  */
 static function create($mapType, $params = array())
 {
     switch ($mapType) {
         default:
             AppDebug::_dx($mapType);
         case self::MAP_TYPE_YANDEX:
             return new YMap($params);
     }
 }
 public function findOneBy(array $criteria, array $orderBy = null)
 {
     $c = $criteria;
     $query = $this->getRepository()->createQueryBuilder('p');
     //            ->orderBy('s.isDefault', 'DESC')
     //            ->andWhere('s.enabled=true')
     //            ->getQuery()->useResultCache(true, 3600)->execute();
     /* @var $query \Doctrine\ORM\QueryBuilder */
     foreach ($c as $k => $v) {
         switch ($k) {
             case 'url':
                 $query->andWhere('p.url=:url')->setParameter('url', $v);
                 unset($c[$k]);
                 break;
             case 'site':
                 $query->andWhere('p.site=:site')->setParameter('site', $v);
                 unset($c[$k]);
                 break;
             case 'routeName':
                 $query->andWhere('p.routeName=:routeName')->setParameter('routeName', $v);
                 unset($c[$k]);
                 break;
             case 'id':
                 $query->andWhere('p.id=:id')->setParameter('id', $v);
                 unset($c[$k]);
                 break;
             default:
                 AppDebug::_dx($c, $k);
         }
     }
     if ($orderBy) {
         AppDebug::_dx($orderBy);
     }
     if (count($c) || $orderBy) {
         return parent::findOneBy($criteria, $orderBy);
     } else {
         try {
             return $query->setMaxResults(1)->getQuery()->useResultCache(true, 300, 'page_')->getSingleResult();
         } catch (NoResultException $e) {
             return null;
         }
     }
 }