Example #1
0
 /**
  * @todo this should get the property via a resolver helper
  * @param GridItem $item
  * @param type $componentId
  * @param Model $model 
  */
 public function populateCell(GridItem $item, $componentId, Model $model)
 {
     $property = $this->propertyName;
     $value = PropertyResolver::get($model->getModelObject(), $property);
     $item->add(new Label($componentId, new BasicModel($value)));
 }
Example #2
0
 /**
  * @todo extract this out to a helper
  * @param type $string
  * @param Model $model 
  */
 private function interpolate($string, Model $model)
 {
     $object = $model->getModelObject();
     if (is_object($object)) {
         $reflection = new \ReflectionClass($object);
         foreach ($reflection->getProperties() as $property) {
             $property->setAccessible(true);
             $name = $property->getName();
             $value = $property->getValue($object);
             if (is_array($value)) {
                 $string = $this->interpolate($string, new ArrayModel($value));
             } else {
                 if (is_object($value)) {
                     throw new \UnsupportedOperationException('Recursive interpolation not supported');
                 } else {
                     $string = str_replace("\${" . $name . "}", $value, $string);
                 }
             }
         }
     } else {
         if (is_array($object)) {
             foreach ($object as $key => $value) {
                 $string = str_replace("\${" . $key . "}", $value, $string);
             }
         }
     }
     return $string;
 }