Esempio n. 1
0
 public function domainAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $ex = null;
     $langUrlForm = $this->createForm(AdminForm::LANG_URL);
     try {
         $form = $this->validateForm($langUrlForm);
         $data = $form->getData();
         $event = new LangUrlEvent();
         foreach ($data as $key => $value) {
             if (false !== strpos($key, LangUrlForm::LANG_PREFIX)) {
                 $event->addUrl(substr($key, strlen(LangUrlForm::LANG_PREFIX)), $value);
             }
         }
         $this->dispatch(TheliaEvents::LANG_URL, $event);
         $response = $this->generateRedirectFromRoute('admin.configuration.languages');
     } catch (FormValidationException $ex) {
         // Form cannot be validated
         $error_msg = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $this->setupFormErrorContext($this->getTranslator()->trans("%obj creation", array('%obj' => 'Lang')), $error_msg, $langUrlForm, $ex);
         // At this point, the form has error, and should be redisplayed.
         $response = $this->renderDefault();
     }
     return $response;
 }
Esempio n. 2
0
 public function langUrl(LangUrlEvent $event)
 {
     foreach ($event->getUrl() as $id => $url) {
         LangQuery::create()->filterById($id)->update(array('Url' => $url));
     }
 }