function newArea($countryslug, Request $request, Application $app)
 {
     if (!$this->build($countryslug, $request, $app)) {
         $app->abort(404, "country does not exist.");
     }
     $areaRepository = new AreaRepository();
     $parentArea = null;
     $parentAreas = array();
     if (isset($_GET['parentAreaSlug'])) {
         $parentArea = $areaRepository->loadBySlugAndCountry($app['currentSite'], $_GET['parentAreaSlug'], $this->parameters['country']);
         // build parent tree, including this area
         $checkArea = $parentArea;
         while ($checkArea) {
             array_unshift($parentAreas, $checkArea);
             $checkArea = $checkArea->getParentAreaId() ? $areaRepository->loadById($checkArea->getParentAreaId()) : null;
         }
     }
     $area = new AreaModel();
     $form = $parentArea ? $app['form.factory']->create(new AreaNewInAreaForm(), $area) : $app['form.factory']->create(new AreaNewInCountryForm(), $area);
     if ('POST' == $request->getMethod()) {
         $form->bind($request);
         if ($form->isValid()) {
             $areaRepository->create($area, $parentArea, $app['currentSite'], $this->parameters['country'], $app['currentUser']);
             $areaRepository->buildCacheAreaHasParent($area);
             return $app->redirect("/admin/areas/" . $this->parameters['country']->getTwoCharCode());
         }
     }
     $this->parameters['parentAreas'] = $parentAreas;
     $this->parameters['form'] = $form->createView();
     return $app['twig']->render('site/adminareas/newarea.html.twig', $this->parameters);
 }