Skip to content

Instantly share code, notes, and snippets.

@kamaulynder
Created July 18, 2014 07:36
Show Gist options
  • Save kamaulynder/b0a86cee99506593b527 to your computer and use it in GitHub Desktop.
Save kamaulynder/b0a86cee99506593b527 to your computer and use it in GitHub Desktop.
public function interact(Tag $tag, TagData $input)
{
if ($input->role)
{
$role = $input->role;
$input->role = json_encode($role);
}
// We only want to work with values that have been changed
$update = $input->getDifferent($tag->asArray());
if (!$this->valid->check($update))
throw new ValidatorException("Failed to validate tag", $this->valid->errors());
// Determine what changes to make in the tag
$this->updated = $update->asArray();
$this->repo->updateTag($tag->id, $this->updated);
// Reflect the changes in the tag
$tag->setData($this->updated);
return $tag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment