docs
docs copied to clipboard
Allow to use class name constants when loading table classes
Description
At the present time you should use a magic string to load a table class:
$articles = $this->getTableLocator()->fetchTable('Articles');.
It would be better to use a constant IMHO:
$articles = $this->getTableLocator()->fetchTable(ArticlesTable::class); and to extract the alias from the class name inside fetchTable method.
In case when an alias does not follow the naming conventions it should be possible to set it by using the options parameter:
$articles = $this->getTableLocator()->fetchTable(ArticlesTable::class, ['alias' => 'MyArticle']);
CakePHP Version
No response
It looks like this has already been implemented but documented neither in method doc blocks nor in the cookbook.
https://github.com/cakephp/cakephp/blob/e8fbbd7f668b30e98293813db600258fadead5a6/tests/TestCase/ORM/Locator/LocatorAwareTraitTest.php#L79
Do you want to make a PR to add a note to the docs?
This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days