Class TableLocator
Provides a default registry/factory for Table objects.
Property Summary
- 
        $_config protectedarrayConfiguration for aliases. 
- 
        $_fallbacked protectedarrayContains a list of Table objects that were created out of the built-in Table class. The list is indexed by table alias 
- 
        $_instances protectedarrayInstances that belong to the registry. 
- 
        $_options protectedarrayContains a list of options that were passed to get() method. 
Method Summary
- 
          _create() protectedWrapper for creating table instances 
- 
          _getClassName() protectedGets the table class name. 
- 
          clear() publicClears the registry of configuration and instances. 
- 
          config() publicStores a list of options to be used when instantiating an object with a matching alias. 
- 
          exists() publicCheck to see if an instance exists in the registry. 
- 
          genericInstances() publicReturns the list of tables that were created by this registry that could not be instantiated from a specific subclass. This method is useful for debugging common mistakes when setting up associations or created new table classes. 
- 
          get() publicGet a table instance from the registry. 
- 
          remove() publicRemoves an instance from the registry. 
- 
          set() publicSet an instance. 
Method Detail
_create() ¶ protected
_create(array $options): Cake\ORM\TableWrapper for creating table instances
Parameters
- 
                array$options
- The alias to check for. 
Returns
Cake\ORM\Table_getClassName() ¶ protected
_getClassName(string $alias, array $options = []): stringGets the table class name.
Parameters
- 
                string$alias
- The alias name you want to get. 
- 
                array$options optional
- Table options array. 
Returns
stringconfig() ¶ public
config(string|null $alias = null, array|null $options = null): arrayStores a list of options to be used when instantiating an object with a matching alias.
The options that can be stored are those that are recognized by get()
If second argument is omitted, it will return the current settings
for $alias.
If no arguments are passed it will return the full configuration array for all aliases
Parameters
- 
                string|null$alias optional
- Name of the alias 
- 
                array|null$options optional
- list of options for the alias 
Returns
arrayThe config data.
Throws
RuntimeExceptionWhen you attempt to configure an existing table instance.
exists() ¶ public
exists(string $alias): boolCheck to see if an instance exists in the registry.
Parameters
- 
                string$alias
Returns
boolgenericInstances() ¶ public
genericInstances(): arrayReturns the list of tables that were created by this registry that could not be instantiated from a specific subclass. This method is useful for debugging common mistakes when setting up associations or created new table classes.
Returns
arrayget() ¶ public
get(string $alias, array $options = []): Cake\ORM\TableGet a table instance from the registry.
Tables are only created once until the registry is flushed. This means that aliases must be unique across your application. This is important because table associations are resolved at runtime and cyclic references need to be handled correctly.
The options that can be passed are the same as in Cake\ORM\Table::__construct(), but the
className key is also recognized.
Options
- classNameDefine the specific class name to use. If undefined, CakePHP will generate the class name based on the alias. For example 'Users' would result in- App\Model\Table\UsersTablebeing used. If this class does not exist, then the default- Cake\ORM\Tableclass will be used. By setting the- classNameoption you can define the specific class to use. The className option supports plugin short class references {@link Cake\Core\App::shortName()}.
- tableDefine the table name to use. If undefined, this option will default to the underscored version of the alias name.
- connectionInject the specific connection object to use. If this option and- connectionNameare undefined, The table class'- defaultConnectionName()method will be invoked to fetch the connection name.
- connectionNameDefine the connection name to use. The named connection will be fetched from Cake\Datasource\ConnectionManager.
Note If your $alias uses plugin syntax only the name part will be used as
key in the registry. This means that if two plugins, or a plugin and app provide
the same alias, the registry will only store the first instance.
Parameters
- 
                string$alias
- The alias name you want to get. 
- 
                array$options optional
- The options you want to build the table with. If a table has already been loaded the options will be ignored. 
Returns
Cake\ORM\TableThrows
RuntimeExceptionWhen you try to configure an alias that already exists.
remove() ¶ public
remove(string $alias): voidRemoves an instance from the registry.
Parameters
- 
                string$alias
Returns
voidset() ¶ public
set(string $alias, Cake\ORM\Table $object): Cake\ORM\TableSet an instance.
Parameters
- 
                string$alias
- 
                Cake\ORM\Table$object
Returns
Cake\ORM\TableProperty Detail
$_fallbacked ¶ protected
Contains a list of Table objects that were created out of the built-in Table class. The list is indexed by table alias
Type
array