protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
         $new = !$form->getObject()->exists();
         $site = $form->save();
         if ($new) {
             $dispatcher = $this->getContext()->getEventDispatcher();
             $formatter = new sfFormatter();
             chdir(sfConfig::get('sf_root_dir'));
             $task = new sfGenerateAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalEnableForAppTask($dispatcher, $formatter);
             $task->run(array($site->slug));
             $task = new sfSympalCreateSiteTask($dispatcher, $formatter);
             $task->run(array($site->slug), array('no-confirmation'));
             $site = Doctrine_Core::getTable('sfSympalSite')->findOneByTitle($site->title);
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $site)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
             $this->redirect('@sympal_sites_new');
         } else {
             $this->redirect('@sympal_sites_edit?id=' . $site->getId());
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
 /**
  * Check if Sympal is installed and redirect to installer if not.
  * Do some other install checks as well.
  *
  * @return void
  */
 private function _checkInstalled()
 {
     $request = $this->_symfonyContext->getRequest();
     // Prepare the symfony application if it has not been prepared yet
     if (!$this->_symfonyContext->getUser() instanceof sfSympalUser) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfSympalEnableForAppTask($this->_dispatcher, new sfFormatter());
         $task->run(array($this->_invoker->getProjectConfiguration()->getApplication()), array());
         $this->_symfonyContext->getController()->redirect('@homepage');
     }
     /*
      * Redirect to install module if...
      *   * not in test environment
      *   * sympal has not been installed
      *   * module is not already sympal_install
      */
     if (sfConfig::get('sf_environment') != 'test' && !sfSympalConfig::get('installed') && $request->getParameter('module') != 'sympal_install') {
         $this->_symfonyContext->getController()->redirect('@sympal_install');
     }
     /*
      * Redirect to homepage if no site record exists so we can prompt the
      * user to create a site record for this application.
      * 
      * This check is only ran in dev mode
      */
     if (sfConfig::get('sf_environment') == 'dev' && !$this->_sympalContext->getSite() && $this->_symfonyContext->getRequest()->getPathInfo() != '/') {
         $this->_symfonyContext->getController()->redirect('@homepage');
     }
 }
 protected function _prepareApplication($application)
 {
     $task = new sfSympalEnableForAppTask($this->dispatcher, $this->formatter);
     $task->run(array($application), array());
 }