Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sidz opened this issue Sep 12, 2023 · 2 comments
Open

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

sidz opened this issue Sep 12, 2023 · 2 comments

Comments

@sidz
Copy link
Contributor

sidz commented Sep 12, 2023

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.

@ariddlestone
Copy link
Owner

Ah - the project I built this for doesn't have models and components which share names. I'll see what I can do!

@sidz
Copy link
Contributor Author

sidz commented Dec 24, 2023

Hey @ariddlestone
I finally found some time to solve the issue described in this ticket. Could you please take a look at #32 when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants