예제 #1
0
 /**
  * @param \Alpixel\Bundle\CMSBundle\Entity\Node $node
  * @return array
  */
 public function findTranslations(Node $node)
 {
     $nodeSource = null;
     // We are checking if the node is the translation provider or translated
     // from an other node
     if ($node->getTranslationSource() !== null) {
         $nodeSource = $node->getTranslationSource();
     } else {
         $nodeSource = $node;
     }
     return $this->createQueryBuilder('n')->addSelect('n')->orWhere('n.translationSource = :source')->orWhere('n.id = :id')->setParameters(['source' => $nodeSource, 'id' => $nodeSource->getId()])->getQuery()->getResult();
 }
예제 #2
0
 public function createTranslation(Node $object, $locale)
 {
     if ($object->getTranslationSource() !== null) {
         $source = $object->getTranslationSource();
     } else {
         $source = $object;
     }
     $node = clone $object;
     $node->setLocale($locale);
     $node->setTranslationSource($source);
     $node->setTitle(sprintf('Version %s de la page "%s"', strtoupper($locale), $node->getTitle()));
     return $node;
 }