Beispiel #1
0
 public function delete(\Message $originalMessage)
 {
     $singular = $originalMessage->getSingular();
     $project = $originalMessage->getTranslation()->getProject();
     $result = $this->dm->createQueryBuilder('Translation')->select('id')->field('project.id')->equals($project->getId())->hydrate(false)->getQuery()->execute()->toArray();
     $ids = array_keys($result);
     $messages = $this->dm->createQueryBuilder('Message')->field('translation.id')->in($ids)->field('singular')->equals($singular)->getQuery()->execute();
     foreach ($messages as $message) {
         $translation = $message->getTranslation();
         $translation->removeMessage($message);
         $this->dm->persist($translation);
         $this->dm->remove($message);
         $this->dm->flush();
     }
     $project->removeTemplateMessage($singular);
     $this->dm->flush();
 }
 public function formDeleteMessageSubmitted(Form $form)
 {
     $values = $form->getValues();
     $message = $this->messageFacade->find($values->id);
     if ($this->translation->hasMessage($message)) {
         $this->messageFacade->delete($message);
         $this->log($this->translation->getProject(), Activity::DELETE_MESSAGE, $message);
         $this->flash(sprintf('Message "%s" has been deleted.', $message->getSingular()));
     }
     $this->redirect('this');
 }
Beispiel #3
0
 /**
  * @param array $messageData
  * @return \Message
  */
 private function prepareMessage($messageData, $translations, $pluralsCount)
 {
     //workaround around something
     if (!isset($messageData['singular'])) {
         $messageData = current($messageData);
     }
     $message = $messageData['singular'];
     $context = 'messages';
     if (isset($messageData['context'])) {
         $context = $messageData['context'];
     } else {
         if (strpos($message, '.') !== FALSE && strpos($message, ' ') === FALSE) {
             list($context, $message) = explode('.', $message, 2);
         }
     }
     $msg = new \Message();
     $msg->setSingular($message)->setPluralsCount($pluralsCount);
     $msg->setContext($context);
     $msg->setTranslations($translations);
     return $msg;
 }