Express Entity as a User Attribute - cant get the associations

Hi,

I am trying to get associations for an Express Entity that I have as a user attribute but all failing for me. I couldnt find any documentation on this.
What I have tried so far:

$u = new \User();
            $ui = \UserInfo::getByID($u->getUserID());
            $user_org= $ui->getAttribute('organisation'); // this works fine 

            $user_proj _= $$user_org->getProjects(); //magic method - the handle name is project and plural projects for this association 
            

Ref: Express Basics :: Concrete CMS

This is erroring out.

Call to undefined method Concrete\Core\Entity\Attribute\Value\Value\ExpressValue::getProjects()

How do I get the association for an Express Entity object? The $user_org is clearly not an Express object is what I think is the reason for this error. Is there a way to make it an Express?

When you var_dump $user_org, what kind of object is it?

Thanks @EvanCooper - After reading through a lot of Concrete APIs, I finally figured this out and following is the right way.

$user_project_entity = $ui->getAttribute('organisation')->getSelectedEntries()[0];
        $u_proj = $user_project_entity->getAssociation('projects');
        $u_proj_entry = $u_proj->getSelectedEntries();

This gives the Entity object.
Thanks for looking into this for me.

1 Like