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
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство 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)

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode Description
__construct ( ) Prevent direct instantiation (Singleton)

Method Details

__clone() final public méthode

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

__construct() protected méthode

Prevent direct instantiation (Singleton)
protected __construct ( )

count() public méthode

Count the elements
public count ( ) : integer
Résultat integer The number of models

fetch() public méthode

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
Résultat Contao\Model | null The model or null

fetchByAlias() public méthode

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
Résultat Contao\Model | null The model or null

getInstance() public static méthode

Return the current object instance (Singleton)
public static getInstance ( ) : static
Résultat static The object instance

isRegistered() public méthode

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

isRegisteredAlias() public méthode

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
Résultat boolean True if the alias is registered

register() public méthode

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

registerAlias() public méthode

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 méthode

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

unregisterAlias() public méthode

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
Résultat array

$arrIdentities protected_oe property

Models by object hash
protected array $arrIdentities
Résultat array

$arrRegistry protected_oe property

Models by table and PK
protected array $arrRegistry
Résultat array

$objInstance protected_oe static_oe property

Object instance (Singleton)
protected static static $objInstance
Résultat static