Exemple #1
0
 /**
  * @param $sourceDocument
  * @param $intendedLanguage
  * @return bool|\Pimcore\Model\Document
  */
 public static function getDocumentInOtherLanguage($sourceDocument, $intendedLanguage)
 {
     if ($sourceDocument instanceof \Pimcore\Model\Document) {
         $documentId = $sourceDocument->getId();
     } else {
         $documentId = $sourceDocument;
     }
     $tSource = new Keys();
     $tTarget = new Keys();
     $select = $tSource->select()->from(array("s" => $tSource->info("name")), array())->from(array("t" => $tTarget->info("name")), array("document_id"))->where("s.document_id = ?", $documentId)->where("s.sourcePath = t.sourcePath")->where("t.language = ?", $intendedLanguage);
     $row = $tSource->fetchRow($select);
     if (!empty($row)) {
         return \Pimcore\Model\Document::getById($row->document_id);
     } else {
         return false;
     }
 }