Provides a default registry/factory for Table objects.
_create( array $options )
Wrapper for creating table instances
$options
Cake\ORM\Table
_getClassName( string $alias , array $options [] )
Gets the table class name.
$alias
$options
optional [] string
clear( )
Clears the registry of configuration and instances.
Cake\ORM\Locator\LocatorInterface::clear()
config( string|null $alias null , array|null $options null )
Stores 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
$alias
optional null $options
optional null array
RuntimeException
Cake\ORM\Locator\LocatorInterface::config()
exists( string $alias )
Check to see if an instance exists in the registry.
$alias
boolean
Cake\ORM\Locator\LocatorInterface::exists()
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.
array
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 Table::__construct()
, but the key className
is also recognized.
If $options does not contain className
CakePHP will attempt to construct the class name based on the alias. For example 'Users' would result in App\Model\Table\UsersTable
being attempted. 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. This className can use a plugin short class reference.
If you use a $name
that 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.
If no table
option is passed, the table name will be the underscored version of the provided $alias.
If no connection
option is passed the table's defaultConnectionName() method will be called to get the default connection name to use.
$alias
$options
optional [] Cake\ORM\Table
RuntimeException
Cake\ORM\Locator\LocatorInterface::get()
remove( string $alias )
Removes an instance from the registry.
$alias
Cake\ORM\Locator\LocatorInterface::remove()
set( string $alias , Cake\ORM\Table $object )
Set an instance.
$alias
Cake\ORM\Table
$object
Cake\ORM\Table
Cake\ORM\Locator\LocatorInterface::set()
© 2005–2016 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.
http://api.cakephp.org/3.1/class-Cake.ORM.Locator.TableLocator.html