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

source() method on aliased plugin Entity #7187

Closed
arilia opened this issue Aug 6, 2015 · 3 comments
Closed

source() method on aliased plugin Entity #7187

arilia opened this issue Aug 6, 2015 · 3 comments

Comments

@arilia
Copy link

arilia commented Aug 6, 2015

about this question I opened in stackoverflow

http://stackoverflow.com/questions/31848771/cakephp-3-0-get-table-object-from-aliased-plugin-entity

what I did

//plugins/Users/src/Model/Table/GroupsTable.php

$this->belongsTo('Parents', [
    'className' => 'Users.Groups',
    'foreignKey' => 'parent_id'
]);

// Some controller

$groupsTable = TableRegistry::get('Users.Groups');
$group = $groupsTable->get($some_id, ['contain' => 'Parents']);
$className =  $group->parent->source();

what I expected

$className contains Users.Parents

what I get

$className contains Parents without the reference to the plugin name

@dereuromark dereuromark added this to the 3.0.12 milestone Aug 6, 2015
@markstory
Copy link
Member

But the source() method returns the 'alias' of the association/class, not the class name. Is this causing you problems?

Ok, I see the issue. The root entities use the prefixed alias, while the associations do not.

@arilia
Copy link
Author

arilia commented Aug 6, 2015

I have an entity, and I need to instantiate its table.

If I use TableRegistry::get(); with the alias I don't get the right table if the entity comes from a plugin. How can I get the entity table? Is there another way than unig source()?

@markstory
Copy link
Member

Pull request up now #7188

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

No branches or pull requests

3 participants