public function bind($src, $ignore = array())
{
if (!\is_object($src) && !\is_array($src)) {
throw new \InvalidArgumentException(sprintf('Could not bind the data source in %1$s::bind(), the source must be an array or object but a "%2$s" was given.', \get_class($this), \gettype($src)));
}
if (!\is_array($ignore)) {
$ignore = explode(' ', $ignore);
}
$event = AbstractEvent::create('onTableBeforeBind', ['subject' => $this, 'src' => $src, 'ignore' => $ignore]);
$this->getDispatcher()->dispatch('onTableBeforeBind', $event);
if (\is_object($src)) {
$src = get_object_vars($src);
}
if (!empty($this->_jsonEncode)) {
foreach ($this->_jsonEncode as $field) {
if (isset($src[$field]) && \is_array($src[$field])) {
$src[$field] = json_encode($src[$field]);
}
}
}
foreach ($this->getProperties() as $k => $v) {
if (!\in_array($k, $ignore)) {
if (isset($src[$k])) {
$this->{$k} = $src[$k];
}
}
}
$event = AbstractEvent::create('onTableAfterBind', ['subject' => $this, 'src' => $src, 'ignore' => $ignore]);
$this->getDispatcher()->dispatch('onTableAfterBind', $event);
return true;
}