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:
<?php
namespace Craft;
return [
'endpoints' => [
'api/settings' => [
'elementType' => 'GlobalSet',
'criteria' => ['handle' => 'siteSettings'],
'first' => true,
'transformer' => function(GlobalSetModel $siteSettings) {
return [
'defaultTitle' => $siteSettings->getContent()['defaultTitle'],
'defaultDescription' => $siteSettings->getContent()['defaultDescription']
];
},
],
]
];
Thanks in advance!