Class IndexLocator
Datasource FactoryLocator compatible locater implementation.
Property Summary
-
$allowFallbackClass protected
bool
Whether fallback class should be used if a Index class could not be found.
-
$fallbackClassName protected
string
Fallback class to use
-
$instances protected
array<string,Cake\Datasource\RepositoryInterface>
Instances that belong to the registry.
-
$options protected
array<string, array>
Contains a list of options that were passed to get() method.
Method Summary
-
allowFallbackClass() public
Set if fallback class should be used.
-
clear() public
Clears the registry of configuration and instances.
-
createInstance() protected
Create an instance of a given classname.
-
exists() public
Check to see if an instance exists in the registry.
-
get() public
Get a repository instance from the registry.
-
remove() public
Removes an repository instance from the registry.
-
set() public
Set a repository instance.
-
setFallbackClassName() public
Set fallback class name.
Method Detail
allowFallbackClass() ¶ public
allowFallbackClass(bool $allow): $this
Set if fallback class should be used.
Controls whether a fallback class should be used to create a index
instance if a concrete class for alias used in get()
could not be found.
Parameters
-
bool
$allow Flag to enable or disable fallback
Returns
$this
createInstance() ¶ protected
createInstance(string $alias, array<string, mixed> $options): Cake\Datasource\RepositoryInterface
Create an instance of a given classname.
Parameters
-
string
$alias -
array<string, mixed>
$options
Returns
Cake\Datasource\RepositoryInterface
exists() ¶ public
exists(string $alias): bool
Check to see if an instance exists in the registry.
Parameters
-
string
$alias
Returns
bool
get() ¶ public
get(string $alias, array<string, mixed> $options = []): Cake\Datasource\RepositoryInterface
Get a repository instance from the registry.
Parameters
-
string
$alias The alias name you want to get.
-
array<string, mixed>
$options optional The options you want to build the table with.
Returns
Cake\Datasource\RepositoryInterface
Throws
Cake\Core\Exception\CakeException
When trying to get alias for which instance has already been created with different options.
remove() ¶ public
remove(string $alias): void
Removes an repository instance from the registry.
Parameters
-
string
$alias
Returns
void
set() ¶ public
set(string $alias, Cake\Datasource\RepositoryInterface $repository): Cake\Datasource\RepositoryInterface
Set a repository instance.
Parameters
-
string
$alias -
Cake\Datasource\RepositoryInterface
$repository
Returns
Cake\Datasource\RepositoryInterface
setFallbackClassName() ¶ public
setFallbackClassName(string $className): $this
Set fallback class name.
The class that should be used to create a table instance if a concrete
class for alias used in get()
could not be found. Defaults to
Cake\Elasticsearch\Index
.
Parameters
-
string
$className Fallback class name
Returns
$this
Property Detail
$allowFallbackClass ¶ protected
Whether fallback class should be used if a Index class could not be found.
Type
bool
$instances ¶ protected
Instances that belong to the registry.
Type
array<string,Cake\Datasource\RepositoryInterface>
$options ¶ protected
Contains a list of options that were passed to get() method.
Type
array<string, array>