Created
September 9, 2013 10:19
-
-
Save oaltman/6493845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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