PHP Class Contao\Model\Registry

The class handles traversing a set of models and lazy loads the database result rows upon their first usage.
Author: Tristan Lins ([email protected])
Inheritance: implements Countable
Datei anzeigen Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrAliases array Aliases to PK's by table and column
$arrIdentities array Models by object hash
$arrRegistry array Models by table and PK
$objInstance static Object instance (Singleton)

Public Methods

Method Description
__clone ( ) Prevent cloning of the object (Singleton)
count ( ) : integer Count the elements
fetch ( string $strTable, mixed $varKey, string $strAlias = null ) : Model | null Fetch a model by table name and primary key
fetchByAlias ( string $strTable, string $strAlias, mixed $varValue ) : Model | null Fetch a model by one of its aliases
getInstance ( ) : static Return the current object instance (Singleton)
isRegistered ( Model $objModel ) : boolean Check if a model is registered
isRegisteredAlias ( Model $objModel, string $strAlias, mixed $varValue ) : boolean Check if an alias is registered
register ( Model $objModel ) Register a model in the registry
registerAlias ( Model $objModel, string $strAlias, mixed $varValue ) Register an alias for a model
unregister ( Model $objModel ) Unregister a model from the registry
unregisterAlias ( Model $objModel, string $strAlias, mixed $varValue ) Unregister an alias

Protected Methods

Method Description
__construct ( ) Prevent direct instantiation (Singleton)

Method Details

__clone() final public method

Prevent cloning of the object (Singleton)
final public __clone ( )

__construct() protected method

Prevent direct instantiation (Singleton)
protected __construct ( )

count() public method

Count the elements
public count ( ) : integer
return integer The number of models

fetch() public method

Fetch a model by table name and primary key
public fetch ( string $strTable, mixed $varKey, string $strAlias = null ) : Model | null
$strTable string The table name
$varKey mixed The key
$strAlias string An optional alias
return Contao\Model | null The model or null

fetchByAlias() public method

Fetch a model by one of its aliases
public fetchByAlias ( string $strTable, string $strAlias, mixed $varValue ) : Model | null
$strTable string The table name
$strAlias string The alias
$varValue mixed The alias value
return Contao\Model | null The model or null

getInstance() public static method

Return the current object instance (Singleton)
public static getInstance ( ) : static
return static The object instance

isRegistered() public method

Check if a model is registered
public isRegistered ( Model $objModel ) : boolean
$objModel Contao\Model The model object
return boolean True if the model is registered

isRegisteredAlias() public method

Check if an alias is registered
public isRegisteredAlias ( Model $objModel, string $strAlias, mixed $varValue ) : boolean
$objModel Contao\Model The model object
$strAlias string The alias name
$varValue mixed The value of the alias
return boolean True if the alias is registered

register() public method

Register a model in the registry
public register ( Model $objModel )
$objModel Contao\Model The model object

registerAlias() public method

Register an alias for a model
public registerAlias ( Model $objModel, string $strAlias, mixed $varValue )
$objModel Contao\Model The model object
$strAlias string The alias name
$varValue mixed The value of the alias

unregister() public method

Unregister a model from the registry
public unregister ( Model $objModel )
$objModel Contao\Model The model object

unregisterAlias() public method

Unregister an alias
public unregisterAlias ( Model $objModel, string $strAlias, mixed $varValue )
$objModel Contao\Model The model object
$strAlias string The alias name
$varValue mixed The value of the alias

Property Details

$arrAliases protected_oe property

Aliases to PK's by table and column
protected array $arrAliases
return array

$arrIdentities protected_oe property

Models by object hash
protected array $arrIdentities
return array

$arrRegistry protected_oe property

Models by table and PK
protected array $arrRegistry
return array

$objInstance protected_oe static_oe property

Object instance (Singleton)
protected static static $objInstance
return static