Skip to content

Allow to use class name constants when loading table classes #8027

@bancer

Description

@bancer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions