Skip to content

Commit

Permalink
convert objects to array on update
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Oct 24, 2017
1 parent f9532ea commit 7824380
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion php/Job/Entity/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Job\Entity;

use Basis\Converter;
use Exception;
use Job\Space\Job;

class Update extends Job
{
public $values;

public function run()
public function run(Converter $converter)
{
$pk = [];
$space = $this->getSpace();
Expand Down Expand Up @@ -47,6 +48,9 @@ public function run()
$entity = $space->getRepository()->findOne($pk);
foreach ($this->values as $k => $v) {
$entity->$k = $v;
if(is_object($v)) {
$entity->$k = $converter->toArray($v);
}
}
$this->getMapper()->save($entity);
}
Expand Down

0 comments on commit 7824380

Please sign in to comment.