How can i get all values in a global set I would like to get all the fields (with their handles and values) for a given global set.

For example : My set is called 'labels'.
I know I can get the set by using :

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::GlobalSet);
$criteria-&gt;handle = 'labels';
$labels = $criteria-&gt;first();


Or with :

$labels = craft()-&gt;globals-&gt;getSetByHandle('labels');


Then I can get a specific data with

$labels-&gt;myDataHandle


But how can I get all the data/fields in the set ?
I would like to have an array or an object with all my labels (in my controller I return the value using returnJson).

Thanks for your help !
Have a look at the answer given here to someone trying to solve this in the template. With a plugin you'd probably do it like so:

public function getFieldsByEntry($entryModel)
{
    $fields = array();
    $fieldLayoutFields = $entryModel-&gt;getFieldLayout()-&gt;getFields();
    foreach ($fieldLayoutFields as $fieldLayoutField)
    {
        $fields[] = craft()-&gt;fields-&gt;getFieldById($fieldLayoutField-&gt;fieldId);
    }
    return $fields;
}