public function testToFromArray()
 {
     $this->configValue->setCode('doctrine')->setScope('datagrid')->setValue('a:2:{s:4:"code";s:8:"test_001";s:4:"type";s:6:"string";}');
     $values = array('is_searchable' => true, 'is_sortable' => false, 'doctrine' => $this->configValue);
     $serializable = array('doctrine' => true);
     $this->configField->addValue(new ConfigModelValue('is_searchable', 'datagrid', false));
     $this->configField->fromArray('datagrid', $values, $serializable);
     $this->assertEquals(array('is_searchable' => 1, 'is_sortable' => 0, 'doctrine' => $this->configValue), $this->configField->toArray('datagrid'));
     $this->configEntity->addValue(new ConfigModelValue('is_searchable', 'datagrid', false));
     $this->configEntity->fromArray('datagrid', $values, $serializable);
     $this->assertEquals(array('is_searchable' => 1, 'is_sortable' => 0, 'doctrine' => $this->configValue), $this->configEntity->toArray('datagrid'));
 }
 /**
  * @param       $scope
  * @param array $values
  * @param array $serializableValues
  */
 public function fromArray($scope, array $values, array $serializableValues = array())
 {
     foreach ($values as $code => $value) {
         $serializable = isset($serializableValues[$code]) && (bool) $serializableValues[$code];
         if (!$serializable && is_bool($value)) {
             $value = (int) $value;
         }
         if (!$serializable && !is_string($value)) {
             $value = (string) $value;
         }
         if ($configValue = $this->getValue($code, $scope)) {
             $configValue->setValue($value);
         } else {
             $configValue = new ConfigModelValue($code, $scope, $value, $serializable);
             if ($this instanceof EntityConfigModel) {
                 $configValue->setEntity($this);
             } else {
                 $configValue->setField($this);
             }
             $this->addValue($configValue);
         }
     }
 }