예제 #1
0
 /**
  * @param $value    string
  * @param $property Reflection_Property ie the contextual Reflection_Property object
  */
 public function __construct($value, Reflection_Property $property)
 {
     parent::__construct($value);
     // default value for @null is true when the property links to a non mandatory object
     if (!$this->value && !$property->getAnnotation('mandatory')->value && $property->getAnnotation('link')->value == Link_Annotation::OBJECT) {
         $this->value = true;
     }
 }
예제 #2
0
 /**
  * Guess value for @link using the type of the property (@var)
  * - property is a Date_Time (or a child class) : @link will be 'DateTime'
  * - property is a single object : @link will be 'Object'
  * - property is a collection object with '@var Object[] All' : @link will be 'All'
  * - property is a collection object with '@var Object[] Collection' : @link will be 'Collection'
  * - property is a collection object with '@var Object[] Map' : @link will be 'Map'
  * - property is a collection object without telling anything :
  *   - @link will be 'Collection' if the object is a Component
  *   - @link will be 'Map' if the object is not a Component
  *
  * @param $property Reflection_Property
  * @return string returned guessed value for @link
  */
 private function guessValue(Reflection_Property $property)
 {
     if ($property->getType()->isMultiple()) {
         /** @var $var_annotation Var_Annotation */
         $value = lParse($property->getAnnotation('var'), SP);
         if (empty($value)) {
             $value = isA($property->getType()->getElementTypeAsString(), Component::class) ? self::COLLECTION : self::MAP;
         }
     } else {
         $value = isA($property->getType()->asString(), Date_Time::class) ? self::DATETIME : self::OBJECT;
     }
     return $value;
 }
예제 #3
0
파일: Loc.php 프로젝트: TuxBoy/Demo-saf
 /**
  * @param $property Reflection_Property
  * @param $value    boolean|integer|float|string|array
  */
 public function beforeObjectBuilderArrayBuildBasicValue(Reflection_Property $property, &$value)
 {
     if (isset($value)) {
         if (is_array($value) && !empty($value)) {
             if ($property->getAnnotation('link')->value == Link_Annotation::COLLECTION) {
                 $class = new Reflection_Class($property->getType()->getElementTypeAsString());
                 $properties = $class->accessProperties();
                 reset($value);
                 if (!is_numeric(key($value))) {
                     $value = arrayFormRevert($value);
                 }
                 foreach ($value as $key => $element) {
                     foreach ($element as $property_name => $property_value) {
                         if (isset($property_value) && isset($properties[$property_name])) {
                             $value[$key][$property_name] = self::propertyToIso($properties[$property_name], $property_value);
                         }
                     }
                 }
             }
         } else {
             $value = self::propertyToIso($property, $value);
         }
     }
 }
예제 #4
0
파일: Locale.php 프로젝트: TuxBoy/Demo-saf
 /**
  * Change an ISO value into a locale formatted value, knowing it's property
  *
  * @param $property Reflection_Property
  * @param $value    string
  * @return string
  */
 public function propertyToLocale(Reflection_Property $property, $value = null)
 {
     if ($property instanceof Reflection_Property_Value && !isset($value)) {
         $value = $property->value();
     }
     return is_null($value) && $property->getAnnotation('null')->value ? $value : $this->toLocale($value, $property->getType());
 }