How to get field values from Global Set using Element API plugin? I'm pulling data from a Global Set using the Element API plugin and am wondering if there's a cleaner way to write the transformer function? 

My craft/config/elementapi.php file looks like this:

&lt;?php
namespace Craft;

return [
    'endpoints' =&gt; [
        'api/settings' =&gt; [
            'elementType' =&gt; 'GlobalSet',
            'criteria' =&gt; ['handle' =&gt; 'siteSettings'],
            'first' =&gt; true,
            'transformer' =&gt; function(GlobalSetModel $siteSettings) {
                return [
                    'defaultTitle' =&gt; $siteSettings-&gt;getContent()['defaultTitle'],
                    'defaultDescription' =&gt; $siteSettings-&gt;getContent()['defaultDescription']
                ];
            },
        ],
    ]
];


Thanks in advance!
There’s no need to go through getContent() to access your field values; you can access them directly from the GlobalSetModel:

'transformer' =&gt; function(GlobalSetModel $siteSettings) {
    return [
        'defaultTitle' =&gt; $siteSettings-&gt;defaultTitle,
        'defaultDescription' =&gt; $siteSettings-&gt;defaultDescription
    ];
},