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;

		if ($varPk === null)
		{
			throw new \RuntimeException('The primary key has not been set');
		}

		// 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);
	}
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;

		if ($varPk === null)
		{
			throw new \RuntimeException('The primary key has not been set');
		}

		// 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);
	}
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 ; if ( $ varPk === null ) { throw new \ RuntimeException ( 'The primary key has not been set' ) ; } // 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 ) ; }
Register a model in the registry

@param Model $objModel The model object

@throws \RuntimeException If the instance exists already
Register a model in the registry