示例#1
0
 /**
  * {@inheritdoc}
  */
 public function &modify(EntityInterface &$instance, array $attributes = null, $save = true)
 {
     if ($attributes) {
         foreach ($attributes as $k => $v) {
             if ($instance->fieldExists($k)) {
                 $instance->setFieldValue($k, $v);
             } else {
                 $instance->setAttribute($k, $v);
             }
         }
     }
     if ($save) {
         $instance->save();
     }
     return $instance;
 }
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage 'not a field' is not a known field
  */
 public function testMissingFieldCantBeSet()
 {
     $this->writer->setFieldValue('not a field', 'yes, a value');
 }