Provides a default registry/factory for Table objects.
array
Configuration for aliases.
\Cake\ORM\Table[]
Contains a list of Table objects that were created out of the built-in Table class. The list is indexed by table alias
\Cake\ORM\Table[]
Instances that belong to the registry.
array
Contains a list of locations where table classes should be looked for.
array
Contains a list of options that were passed to get() method.
Returns 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 configuration for an alias or the full configuration array for all aliases.
Stores a list of options to be used when instantiating an object with a matching alias.
__construct(?array $locations)
Constructor.
array|null
$locations optional Locations where tables should be looked for. If none provided, the default Model\Table
under your app's namespace is used.
_create(array $options)
Wrapper for creating table instances
array
$options The alias to check for.
\Cake\ORM\Table
_getClassName(string $alias, array $options)
Gets the table class name.
string
$alias The alias name you want to get. Should be in CamelCase format.
array
$options optional Table options array.
string|null
addLocation(string $location)
Adds a location where tables should be looked for.
string
$location Location to add.
$this
clear()
Clears the registry of configuration and instances.
createInstance(string $alias, array $options)
Create an instance of a given classname.
string
$alias Repository alias.
array
$options The options you want to build the instance with.
\Cake\Datasource\RepositoryInterface
exists(string $alias)
Check to see if an instance exists in the registry.
string
$alias The alias to check for.
bool
genericInstances()
Returns 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.
\Cake\ORM\Table[]
get(string $alias, array $options)
Get 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.
className
Define 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\UsersTable
being used. If this class does not exist, then the default Cake\ORM\Table
class will be used. By setting the className
option you can define the specific class to use. The className option supports plugin short class references {@link \Cake\Core\App::shortName()}.table
Define the table name to use. If undefined, this option will default to the underscored version of the alias name.connection
Inject the specific connection object to use. If this option and connectionName
are undefined, The table class' defaultConnectionName()
method will be invoked to fetch the connection name.connectionName
Define the connection name to use. The named connection will be fetched from {@link \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.
string
$alias The alias name you want to get. Should be in CamelCase format.
array
$options optional The options you want to build the table with. If a table has already been loaded the options will be ignored.
\Cake\ORM\Table
RuntimeException
getConfig(?string $alias)
Returns configuration for an alias or the full configuration array for all aliases.
string|null
$alias optional Alias to get config for, null for complete config.
array
The config data.
remove(string $alias)
Removes an repository instance from the registry.
string
$alias The alias to remove.
set(string $alias, \Cake\Datasource\RepositoryInterface $repository)
Set a Table instance.
string
$alias The alias to set.
\Cake\ORM\Table
$repository The Table to set.
\Cake\ORM\Table
setConfig(mixed $alias, mixed $options)
Stores a list of options to be used when instantiating an object with a matching alias.
string|array
$alias Name of the alias or array to completely overwrite current config.
array|null
$options optional list of options for the alias
$this
RuntimeException
Configuration for aliases.
array
Contains a list of Table objects that were created out of the built-in Table class. The list is indexed by table alias
\Cake\ORM\Table[]
Instances that belong to the registry.
\Cake\ORM\Table[]
Contains a list of locations where table classes should be looked for.
array
Contains a list of options that were passed to get() method.
array
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.ORM.Locator.TableLocator.html