/**
  * {@inheritdoc}
  */
 protected function getValue($value)
 {
     if (is_array($value) || $value instanceof \Traversable) {
         $value = null;
     } elseif ($value instanceof \DateTime) {
         $value = $value->format($this->dateTimeFormat);
     } elseif (is_object($value)) {
         $value = (string) $value;
     } elseif (is_bool($value)) {
         $value == true ? $value = $this->translator->trans('label_type_yes', [], 'SonataAdminBundle') : ($value = $this->translator->trans('label_type_no', [], 'SonataAdminBundle'));
     } else {
         $value = $this->translator->trans($value);
     }
     return $value;
 }
 /**
  * @throws TranslationsNotFoundException
  */
 public function assertAllTranslationsFound()
 {
     $missings = array();
     foreach ($this->dataCollectorTranslator->getCollectedMessages() as $message) {
         if ($message['state'] === DataCollectorTranslator::MESSAGE_MISSING) {
             $missings[] = $message;
         } elseif ($message['state'] === DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK && $this->allowFallbacks === false) {
             $message['locale'] = 'fallback ' . $message['locale'] . ' found ';
             $message['locale'] .= 'but not allowed by config dev.translation.allow_fallbacks)';
             $missings[] = $message;
         }
     }
     if (count($missings) > 0) {
         throw new TranslationsNotFoundException($missings);
     }
 }
Beispiel #3
0
 public function onTerminate(Event $event)
 {
     if ($this->translator === null) {
         return;
     }
     $messages = $this->translator->getCollectedMessages();
     $created = array();
     foreach ($messages as $message) {
         if ($message['state'] === DataCollectorTranslator::MESSAGE_MISSING) {
             $m = new Message($message);
             $this->transService->createAsset($m);
             $created[] = $m;
         }
     }
     if (count($created) > 0) {
         // update filesystem
         $this->fileSystemUpdater->updateMessageCatalog($created);
     }
 }
 /**
  * Init ppa
  * @param type $configGlobale
  * @param Translator $translator
  */
 public function __construct($configGlobale, Translator $translator, $rootDir)
 {
     // traduction
     $this->translator = $translator;
     // web ppa path
     $this->dirRoot = $rootDir . '/web/ppa';
     // report path
     $this->reportPath = $this->dirRoot . '/reports';
     // parameters
     $this->parameters = $configGlobale;
     // l'objet analyse
     $this->oAnalyze = new Analyze();
     $this->oAnalyze->setLang($translator->getLocale())->setNbNamespace($this->extractFromLoc('namespaces'))->setNbClasses($this->extractFromLoc('classes'))->setNbMethod($this->extractFromLoc('methods'))->setLoc((int) $this->extractFromLoc('loc'));
     // Exploits analysis
     $this->count();
     $this->setSecurityInfo();
     $this->setQualityInfo();
     $this->setAnalysisTimeInfo();
     $this->exploitTestReport();
     $this->calculateScore();
 }
 /**
  * Checks logged user is owner of voted post
  * 
  * @param Post $post
  * 
  * @return JsonResponse|RedirectResponse|null
  */
 private function checkOwner(Post $post)
 {
     if ($this->getUser()) {
         if ($post->getAuthor()->getId() == $this->getUser()->getId()) {
             $message = $this->translator->trans('you.can.not.vote.for.your.posts');
             $this->addFlash('danger', $message);
             if ($this->request->isXmlHttpRequest()) {
                 return new JsonResponse(array('result' => false, 'message' => $message));
             }
             return $this->redirect($this->generateUrl('topic_show', array('slug' => $post->getTopic()->getSlug())));
         }
     }
     return null;
 }
 /**
  * Adds Topic to database if form is valid
  * 
  * @param Form  $topicForm
  * @param Topic $topic
  * @param string   $parentSlug
  * 
  * @return RedirectResponse|null
  */
 protected function addTopic(Form $topicForm, Topic $topic, $parentSlug)
 {
     $topicForm->handleRequest($this->request);
     if ($topicForm->isValid()) {
         try {
             $this->getDoctrine()->getManager()->getFilters()->disable('softdeleteable');
             $this->getTopicManager()->update($topic);
             $this->getDoctrine()->getManager()->getFilters()->enable('softdeleteable');
             $this->addFlash('success', $this->translator->trans('topic.has.been.created'));
             return $this->redirect($this->generateUrl('topic_show', array('slug' => $topic->getSlug())));
         } catch (Exception $ex) {
             throw $ex;
             $this->addFlash('danger', $this->translator->trans('topic.has.not.been.created'));
             return $this->redirect($this->generateUrl('forum_index', array('slug' => $parentSlug)));
         }
     }
     return;
 }
 /**
  * Deletes topic by slug
  * 
  * @param string $slug
  * 
  * @return RedirectResponse
  * 
  * @throws Exception
  */
 public function deleteTopicAction($slug)
 {
     $topic = $this->getTopicManager()->findOneBy(array('slug' => $slug));
     if (!$topic) {
         throw $this->createNotFoundException(sprintf('Topic with slug %s does not exists', $slug));
     }
     if (!$this->isLoggedAsAdmin()) {
         $this->denyAccessUnlessGranted('ROLE_FORUM_ADMIN', null, 'Unable to access this page!');
     }
     $parentSlug = $topic->getForum()->getSlug();
     try {
         $this->getTopicManager()->remove($topic);
         $this->addFlash('success', $this->translator->trans('topic.has.been.removed'));
     } catch (Exception $ex) {
         $this->addFlash('danger', $this->translator->trans('topic.has.not.been.removed'));
     }
     return $this->redirect($this->generateUrl('forum_index', array('slug' => $parentSlug)));
 }
 /**
  * {@inheritdoc}
  */
 public function lateCollect()
 {
     $messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
     $this->data = $this->computeCount($messages);
     $this->data['messages'] = $messages;
 }
 /** Translates a string
  *
  * @param $string
  *
  * @return string
  */
 private function _trans($string)
 {
     return $this->translator->trans($string, array(), 'TrainingScheduleBundle');
 }
Beispiel #10
0
 public function __construct(\Symfony\Component\Translation\DataCollectorTranslator $translator)
 {
     $this->_locale = $translator->getLocale();
     $this->_trad1 = $translator->trans('windsurfdb.matos.form.marque.type_choice.board');
     $this->_trad2 = $translator->trans('windsurfdb.matos.form.marque.type_choice.voile');
 }
Beispiel #11
0
 public function __construct(\Symfony\Component\Translation\DataCollectorTranslator $translator, $localeDefault)
 {
     $this->_locale = $translator->getLocale();
     var_dump($this->_locale);
 }
 /**
  * @return array Translated week days in array
  */
 public function getWeekNames()
 {
     return array(0 => $this->translator->trans('weekdays.monday', array(), 'TrainingScheduleBundle'), 1 => $this->translator->trans('weekdays.tuesday', array(), 'TrainingScheduleBundle'), 2 => $this->translator->trans('weekdays.wednesday', array(), 'TrainingScheduleBundle'), 3 => $this->translator->trans('weekdays.thursday', array(), 'TrainingScheduleBundle'), 4 => $this->translator->trans('weekdays.friday', array(), 'TrainingScheduleBundle'), 5 => $this->translator->trans('weekdays.saturday', array(), 'TrainingScheduleBundle'), 6 => $this->translator->trans('weekdays.sunday', array(), 'TrainingScheduleBundle'));
 }