示例#1
0
 /**
  * Gets the locale to use for translation. Loads entity
  * defined locale first..
  * 
  * @param object $entity
  * @param ClassMetadata $meta
  * @return string
  */
 public function getTranslatableLocale($entity, ClassMetadata $meta)
 {
     $locale = $this->_locale;
     if (isset($this->_configurations[$meta->name]['locale'])) {
         $class = $meta->getReflectionClass();
         $reflectionProperty = $class->getProperty($this->_configurations[$meta->name]['locale']);
         if (!$reflectionProperty) {
             throw Exception::entityMissingLocaleProperty($this->_configurations[$meta->name]['locale'], $meta->name);
         }
         $reflectionProperty->setAccessible(true);
         $value = $reflectionProperty->getValue($entity);
         if (is_string($value) && strlen($value)) {
             $locale = $value;
         }
     }
     return $locale;
 }