public function bind($data, $ignore = array())
{
$this->triggerEvent('onBeforeBind', array(&$data));
// If the source value is not an array or object return false.
if (!is_object($data) && !is_array($data)) {
throw new \InvalidArgumentException(\JText::sprintf('LIB_FOF_MODEL_ERR_BIND', get_class($this), gettype($data)));
}
// If the ignore value is a string, explode it over spaces.
if (!is_array($ignore)) {
$ignore = explode(' ', $ignore);
}
// Bind the source value, excluding the ignored fields.
foreach ($this->recordData as $k => $currentValue) {
// Only process fields not in the ignore array.
if (!in_array($k, $ignore)) {
if (is_array($data) && isset($data[$k])) {
$this->setFieldValue($k, $data[$k]);
} elseif (is_object($data) && isset($data->{$k})) {
$this->setFieldValue($k, $data->{$k});
}
}
}
// Perform data transformation
$this->databaseDataToRecordData();
$this->triggerEvent('onAfterBind', array($data));
return $this;
}