protected function run()
 {
     $areaRepository = new AreaRepository();
     $arb = new AreaRepositoryBuilder();
     $arb->setLimit(0);
     // all of them
     $count = 0;
     foreach ($arb->fetchAll() as $area) {
         $areaRepository->updateFutureEventsCache($area);
         ++$count;
     }
     return array('result' => 'ok', 'count' => $count);
 }
 protected function run()
 {
     $areaRepository = new AreaRepository();
     $arb = new AreaRepositoryBuilder();
     $arb->setLimit(0);
     // all of them
     $arb->setCacheNeedsBuildingOnly(true);
     $count = 0;
     foreach ($arb->fetchAll() as $area) {
         $areaRepository->buildCacheAreaHasParent($area);
         ++$count;
     }
     return array('result' => 'ok', 'count' => $count);
 }
 /**
  * @return array
  */
 public function getUserNotifyContentForSiteAndUser(SiteModel $siteModel, UserAccountModel $userAccountModel)
 {
     global $CONFIG;
     $out = array();
     $grb = new AreaRepositoryBuilder();
     $grb->setSite($siteModel);
     $grb->setLimit(0);
     // all! No limit
     // TODO  don't we still want to do this? How will user A get a notification if user B deletes area? but then so far most area deletetions are by admins.
     $grb->setIncludeDeleted(false);
     foreach ($grb->fetchAll() as $area) {
         $uwg = $this->loadByUserAndArea($userAccountModel, $area);
         if ($uwg && $uwg->getIsWatching()) {
             $dateSince = $uwg->getSinceDateForNotifyChecking();
             $historyRepositoryBuilder = new HistoryRepositoryBuilder();
             $historyRepositoryBuilder->getHistoryRepositoryBuilderConfig()->setArea($area);
             $historyRepositoryBuilder->setSince($dateSince);
             $historyRepositoryBuilder->setNotUser($userAccountModel);
             // Only admins can change tags at the moment so don't include
             $historyRepositoryBuilder->setIncludeTagHistory(false);
             $histories = $historyRepositoryBuilder->fetchAll();
             if ($histories) {
                 $content = new UserWatchesAreaNotifyContent();
                 $content->setHistories($histories);
                 $userWatchesAreaStopRepository = new UserWatchesAreaStopRepository();
                 $userWatchesAreaStop = $userWatchesAreaStopRepository->getForUserAndArea($userAccountModel, $area);
                 $content->setUnwatchURL($CONFIG->getWebSiteDomainSecure($siteModel->getSlug()) . '/area/' . $area->getSlugForURL() . '/stopWatchingFromEmail/' . $userAccountModel->getId() . '/' . $userWatchesAreaStop->getAccessKey());
                 $content->setUserAccount($userAccountModel);
                 $content->setSite($siteModel);
                 $content->setArea($area);
                 $content->setWatchedThingTitle($area->getTitle());
                 $content->setWatchedThingURL($CONFIG->getWebSiteDomainSecure($siteModel->getSlug()) . '/area/' . $area->getSlugForURL() . '/history');
                 $out[] = $content;
             }
         }
     }
     return $out;
 }
 protected function getChildAreasForArea(AreaModel $areaModel = null, $limit = 500)
 {
     $arb = new AreaRepositoryBuilder();
     $arb->setSite($this->site);
     $arb->setIncludeDeleted(false);
     if ($areaModel) {
         $arb->setParentArea($areaModel);
     } else {
         $arb->setNoParentArea(true);
     }
     $arb->setLimit($limit);
     return $arb->fetchAll();
 }