Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Reduce complexity in Registry::fetch()
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Mar 30, 2015
1 parent 7032e63 commit 81bd651
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions system/modules/core/library/Contao/Model/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,24 @@ public function fetch($strTable, $varKey, $strAlias = null)
}

// Try to find in aliases
if (isset($this->arrRegistryAliases[$strTable][$strAlias][$varKey]))
return $this->fetchByAlias($strTable, $strAlias, $varKey);
}


/**
* Fetch a model by an alias
*
* @param string $strTable The table name
* @param string $strAlias The alias
* @param mixed $varValue The alias value
*
* @return \Model|null The model or null
*/
public function fetchByAlias($strTable, $strAlias, $varValue)
{
if (isset($this->arrRegistryAliases[$strTable][$strAlias][$varValue]))
{
$strPk = $this->arrRegistryAliases[$strTable][$strAlias][$varKey];
$strPk = $this->arrRegistryAliases[$strTable][$strAlias][$varValue];

if (isset($this->arrRegistry[$strTable][$strPk]))
{
Expand Down

0 comments on commit 81bd651

Please sign in to comment.