Example #1
0
    public function translationInformation($className)
    {
        if (!isset($this->propertyInformation[$className])) {

            $translated = __NAMESPACE__.'\Translated';
            $language   = __NAMESPACE__.'\Language';

            $info = new Information();
            $translatedProperties = array();

            $refClass = new \ReflectionClass($className);
            $refProps = $refClass->getProperties();
            foreach ($refProps as $refProp) {

                $annotations = $this->reader->getPropertyAnnotations($refProp);
                if (count($annotations)) {
                    $refPropName = $refProp->getName();

                    if (isset($annotations[$language])) {
                        $info->setLanguageIndicator($refPropName);
                        $info->addTranslatedProperty($refPropName);
                    } else if (isset($annotations[$translated])) {
                        $info->addTranslatedProperty($refPropName);
                    }
                }
            }

            $this->propertyInformation[$className] = $info;
        }

        return $this->propertyInformation[$className];

    }
Example #2
0
 public function translationInformation($className)
 {
     if (!isset($this->propertyInformation[$className])) {
         $info = new Information();
         $translatedProperties = array();
         $refClass = new \ReflectionClass($className);
         foreach ($this->reader->getClassAnnotations($refClass) as $annotation) {
             if ($annotation instanceof Multilang) {
                 if (isset($annotation->strategy)) {
                     $info->setTranslationStrategy($annotation->strategy);
                 }
             }
         }
         $refProps = $refClass->getProperties();
         foreach ($refProps as $refProp) {
             $annotations = $this->reader->getPropertyAnnotations($refProp);
             if (count($annotations)) {
                 /* TODO: should we support a name parameter in the
                  * annotation for the phpcr node property name? here we
                  * always use the same name as the document property.
                  */
                 $refPropName = $refProp->getName();
                 foreach ($annotations as $annotation) {
                     if ($annotation instanceof Language) {
                         $info->setLanguageIndicator($refPropName);
                         $info->addTranslatedProperty($refPropName);
                     } elseif ($annotation instanceof Translated) {
                         $info->addTranslatedProperty($refPropName);
                     }
                 }
             }
         }
         $this->propertyInformation[$className] = $info;
     }
     return $this->propertyInformation[$className];
 }