setPrevalueValue() public method

Set prevalue value
public setPrevalueValue ( mixed $value ) : Model
$value mixed Value
return Model
Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testSetPrevalueValue()
 {
     $this->object->setPrevalueValue('s:11:"string test";');
     $this->assertEquals('string test', $this->object->getPrevalueValue());
     $this->object->setPrevalueValue(array('array test'));
     $this->assertEquals(array('array test'), $this->object->getPrevalueValue());
 }
Beispiel #2
0
 /**
  * Import Datatypes
  *
  * @param array &$ids     Ids
  * @param array &$errors  Errors
  * @param array $children Children list
  *
  * @return void
  */
 protected function importDatatypes(&$ids, &$errors, $children)
 {
     foreach ($children['children'] as $child) {
         $attributes = $child->attributes();
         $id = (int) $attributes['id'];
         $model = Datatype\Model::fromId($id);
         if ($model === false) {
             $model = new Datatype\Model();
         }
         $name = (string) $child->name;
         $datatypeModel = (string) $child->model;
         $model->addData(array('name' => empty($name) ? $model->getName() : $name, 'model' => empty($datatypeModel) ? $model->getModel() : $datatypeModel));
         $model->setPrevalueValue((string) $child->prevalue_value);
         try {
             if (!empty($model)) {
                 $model->save();
                 $ids['datatypes'][$id] = $model->getId();
             }
         } catch (Exception $e) {
             $errors[] = sprintf($this->serviceLocator->get('MvcTranslator')->translate('Cannot save datatype with id (%d)'), $id);
         }
     }
 }