CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • TableLocator

Interfaces

  • LocatorInterface

Traits

  • LocatorAwareTrait

Class TableLocator

Provides a default registry/factory for Table objects.

Cake\ORM\Locator\TableLocator implements Cake\ORM\Locator\LocatorInterface
Namespace: Cake\ORM\Locator
Location: ORM/Locator/TableLocator.php

Properties summary

  • $_config protected
    array
    Configuration for aliases.
  • $_fallbacked protected
    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

  • $_instances protected
    Cake\ORM\Table[]
    Instances that belong to the registry.
  • $_options protected
    array
    Contains a list of options that were passed to get() method.
  • $locations protected
    array
    Contains a list of locations where table classes should be looked for.

Method Summary

  • __construct() public
    Constructor.
  • _create() protected
    Wrapper for creating table instances
  • _getClassName() protected
    Gets the table class name.
  • addLocation() public
    Adds a location where tables should be looked for.
  • clear() public
    Clears the registry of configuration and instances.
  • config() public deprecated

    Stores a list of options to be used when instantiating an object with a matching alias.

  • exists() public
    Check to see if an instance exists in the registry.
  • genericInstances() public

    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.

  • get() public
    Get a table instance from the registry.
  • getConfig() public
    Returns configuration for an alias or the full configuration array for all aliases.
  • remove() public
    Removes an instance from the registry.
  • set() public
    Set an instance.
  • setConfig() public

    Stores a list of options to be used when instantiating an object with a matching alias.

Method Detail

__construct() public ¶

__construct( array $locations = null )

Constructor.

Parameters
array $locations optional null

Locations where tables should be looked for. If none provided, the default Model\Table under your app's namespace is used.

_create() protected ¶

_create( array $options )

Wrapper for creating table instances

Parameters
array $options
The alias to check for.
Returns
Cake\ORM\Table

_getClassName() protected ¶

_getClassName( string $alias , array $options = [] )

Gets the table class name.

Parameters
string $alias
The alias name you want to get.
array $options optional []
Table options array.
Returns
string|false

addLocation() public ¶

addLocation( string $location )

Adds a location where tables should be looked for.

Parameters
string $location
Location to add.
Returns

$this
Since
3.8.0

clear() public ¶

clear( )

Clears the registry of configuration and instances.

Implementation of
Cake\ORM\Locator\LocatorInterface::clear()

config() public deprecated ¶

config( string|array|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

Deprecated
3.4.0 Use setConfig()/getConfig() instead.
Parameters
string|array|null $alias optional null
Name of the alias
array|null $options optional null
list of options for the alias
Returns
array
The config data.
Throws
RuntimeException
When you attempt to configure an existing table instance.
Implementation of
Cake\ORM\Locator\LocatorInterface::config()

exists() public ¶

exists( string $alias )

Check to see if an instance exists in the registry.

Parameters
string $alias
The alias to check for.
Returns
boolean
Implementation of
Cake\ORM\Locator\LocatorInterface::exists()

genericInstances() public ¶

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.

Returns
Cake\ORM\Table[]

get() public ¶

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.

Options

  • 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 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 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\Table
Throws
RuntimeException
When you try to configure an alias that already exists.
Implementation of
Cake\ORM\Locator\LocatorInterface::get()

getConfig() public ¶

getConfig( string|null $alias = null )

Returns configuration for an alias or the full configuration array for all aliases.

Parameters
string|null $alias optional null
Alias to get config for, null for complete config.
Returns
array
The config data.

remove() public ¶

remove( string $alias )

Removes an instance from the registry.

Parameters
string $alias
The alias to remove.
Implementation of
Cake\ORM\Locator\LocatorInterface::remove()

set() public ¶

set( string $alias , Cake\ORM\Table $object )

Set an instance.

Parameters
string $alias
The alias to set.
Cake\ORM\Table $object
The table to set.
Returns
Cake\ORM\Table
Implementation of
Cake\ORM\Locator\LocatorInterface::set()

setConfig() public ¶

setConfig( string|array $alias , array|null $options = null )

Stores a list of options to be used when instantiating an object with a matching alias.

Parameters
string|array $alias
Name of the alias or array to completely overwrite current config.
array|null $options optional null
list of options for the alias
Returns

$this
Throws
RuntimeException
When you attempt to configure an existing table instance.

Magic methods inherited from Cake\ORM\Locator\LocatorInterface

getConfig()

Properties detail

$_config ¶

protected array

Configuration for aliases.

[]

$_fallbacked ¶

protected 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

[]

$_instances ¶

protected Cake\ORM\Table[]

Instances that belong to the registry.

[]

$_options ¶

protected array

Contains a list of options that were passed to get() method.

[]

$locations ¶

protected array

Contains a list of locations where table classes should be looked for.

[]
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs