doLoadTranslation() 공개 메소드

If locale is not set then the current locale of the document is reloaded, resetting possible changes. If the document is not translatable, this method returns immediately and without error.
public doLoadTranslation ( object $document, ClassMetadata $metadata, string $locale = null, boolean $fallback = false, boolean $refresh = false )
$document object
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$locale string The locale to use or null if the default locale should be used
$fallback boolean Whether to do try other languages
$refresh boolean
예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function findTranslation($className, $id, $locale, $fallback = true)
 {
     try {
         if (UUIDHelper::isUUID($id)) {
             try {
                 $id = $this->session->getNodeByIdentifier($id)->getPath();
             } catch (ItemNotFoundException $e) {
                 return null;
             }
         } elseif (strpos($id, '/') !== 0) {
             $id = '/' . $id;
         }
         $document = $this->unitOfWork->getDocumentById($id);
         if ($document) {
             $this->unitOfWork->validateClassName($document, $className);
             $class = $this->getClassMetadata(get_class($document));
             $this->unitOfWork->doLoadTranslation($document, $class, $locale, $fallback);
             return $document;
         }
         $node = $this->session->getNode($id);
     } catch (PathNotFoundException $e) {
         return null;
     }
     $hints = array('locale' => $locale, 'fallback' => $fallback);
     return $this->unitOfWork->getOrCreateDocument($className, $node, $hints);
 }