/** * 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()); }
/** * 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); } } }