How to find list of options from Express Dropdown attribute

Permalink
Something else that I'm spending far too long trying to find out so hopefully someone else knows and has suffered the pain for me...

I know the handle of my express entity and one of its option attributes. How do I get a list of the defined values from the attribute?

I have done this elsewhere with option attributes (e.g. page) but I can't find specifically how to get the attribute from the Express object. Can't find any documentation (plus ca change...)

surefyre
 
surefyre replied on at Permalink Best Answer Reply
surefyre
I finally got lucky having resorted to recursively grepping the whole /concrete dir for 'attribute.*byhandle'. Less than ideal.

To get a list of dropdown options from an Entity's option Attribute I did this:
$attr = \Express::getObjectByHandle('dblsession')->getAttributeKeyCategory()->getByHandle('session_course_type'); // gets the attribute
        $atc = $attr->getController();
        $options = $atc->getOptions();       
        $course_types = [];
        foreach ($options as $v) {
            $course_types[] = (string)$v;
        }


$course_types ends up with the available options in it.