public function __construct($data = [], $options = [])
{
if ($data instanceof Result) {
$options['result'] = $data;
$id = $data->getId();
$data = $data->getData();
if ($id !== []) {
$data['id'] = $id;
}
}
$options += ['useSetters' => true, 'markClean' => false, 'markNew' => null, 'guard' => false, 'source' => null, 'result' => null];
if (!empty($options['source'])) {
$this->source($options['source']);
}
if ($options['markNew'] !== null) {
$this->isNew($options['markNew']);
}
if ($options['result'] !== null) {
$this->_result = $options['result'];
}
if (!empty($data) && $options['markClean'] && !$options['useSetters']) {
$this->_properties = $data;
return;
}
if (!empty($data)) {
$this->set($data, ['setter' => $options['useSetters'], 'guard' => $options['guard']]);
}
if ($options['markClean']) {
$this->clean();
}
}