예제 #1
0
파일: __flex.php 프로젝트: pdelbar/onethree
 /**
  * Convert all the excessive data into a json string
  *
  * @param One_Scheme $scheme
  * @param One_Model $model
  */
 private function flexToJson(One_Scheme $scheme, One_Model $model)
 {
     $ignoreAttributes = array_merge(self::$_ignoreAttributes, $scheme->getForeignKeys());
     // ignore all local foreign key attributes as well
     $bOptions = $scheme->get('behaviorOptions.' . strtolower($this->getName()));
     $flexfield = $bOptions['flexfield'];
     unset($model->{$flexfield});
     // Flexfields should not be set manually
     //		// only auto-set the flexfield, if it's not in the modified fields
     //		// if it is set in the modified fields, then the flex field was intentionally set manually
     //		if(!array_key_exists($flexfield, $model->getModified()))
     //		{
     $data = $model->toArray();
     $attributes = $scheme->get('attributes');
     foreach ($attributes as $attr) {
         unset($data[$attr->getName()]);
     }
     foreach ($ignoreAttributes as $ignore) {
         unset($data[$ignore]);
     }
     $model->{$flexfield} = json_encode($data);
     //		}
 }