public function register(Model $objModel)
{
$intObjectId = spl_object_hash($objModel);
// The model has been registered already
if (isset($this->arrIdentities[$intObjectId])) {
return;
}
$strTable = $objModel->getTable();
if (!is_array($this->arrAliases[$strTable])) {
$this->arrAliases[$strTable] = array();
}
if (!is_array($this->arrRegistry[$strTable])) {
$this->arrRegistry[$strTable] = array();
}
$strPk = $objModel->getPk();
$varPk = $objModel->{$strPk};
// Another model object is pointing to the DB record already
if (isset($this->arrRegistry[$strTable][$varPk])) {
throw new \RuntimeException("The registry already contains an instance for {$strTable}::{$strPk}({$varPk})");
}
$this->arrIdentities[$intObjectId] = $objModel;
$this->arrRegistry[$strTable][$varPk] = $objModel;
// Allow the model to modify the registry
$objModel->onRegister($this);
}