Skip to content

Instantly share code, notes, and snippets.

@oaltman
Created September 9, 2013 10:19
Show Gist options
  • Save oaltman/6493845 to your computer and use it in GitHub Desktop.
Save oaltman/6493845 to your computer and use it in GitHub Desktop.
class BaseEntity extends IdentifiedEntity {
public function __construct($data = NULL)
{
parent::__construct();
if($data)
$this->setData($data);
}
public function setData($data)
{
if (!is_array($data) && !($data instanceof ArrayHash))
throw new InvalidArgumentException('Data musi byt typu array nebo \\Nette\\ArrayHash.');
if (is_array($data)) $data = ArrayHash::from($data);
foreach ($data as $key=>$value) {
$this->$key = $value;
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment