Skip to content

Undefined method appears when Component and Model have the same name #29

@sidz

Description

@sidz

Hi.

Thanks for this brilliant extension first of all.

I'm working with project where all Models don't have Model suffix. Like described in the official documentation (https://book.cakephp.org/2/en/models.html#understanding-models)

So in case we have Component and Model with the same name it leads to Call to an undefined method BasicComponent::some_method.

Code sample:

<?php

class BasicComponent extends Component {}
<?php

class Basic extends Model
{
    public function some_method()
    {
    }
}
<?php

class FakeController extends Controller
{
    public $uses = [
        'Basic',
    ];

    public function add_smth()
    {
        $this->Basic->some_method();
    }
}

As I can see component service is setup first so probably it found BasicComponent and tries to look method inside of it only and doesn't take into account that models is also exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions