<?php
namespace Craft;
return [
'endpoints' => [
'locations.json' => [
'elementType' => 'Entry',
'criteria' => [
'section' => 'locations',
'type' => 'location'
],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'latitude' => $entry->latitude,
'longitude' => $entry->longitude,
'jsonUrl' => UrlHelper::getUrl("locations/{$entry->id}.json")
];
},
],
'locations/<slug:{slug}>.json' => function($slug) {
return [
'elementType' => 'Entry',
'criteria' => [
'section' => 'locations',
'type' => 'state',
'slug' => $slug
],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'latitude' => $entry->latitude,
'longitude' => $entry->longitude,
'jsonUrl' => UrlHelper::getUrl("locations/{$entry->id}.json")
];
},
];
},
]
];
<?php
namespace Craft;
return [
'endpoints' => [
'locations.json' => [
'elementType' => 'Entry',
'criteria' => [
'section' => 'locations',
'type' => 'location'
],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'latitude' => $entry->latitude,
'longitude' => $entry->longitude,
'jsonUrl' => UrlHelper::getUrl("locations/{$entry->id}.json")
];
},
],
'locations/<slug:{slug}>.json' => function($slug) {
return [
'elementType' => 'Entry',
'criteria' => [
'section' => 'locations',
'type' => 'state',
'slug' => $slug
],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'latitude' => $entry->latitude,
'longitude' => $entry->longitude,
'jsonUrl' => UrlHelper::getUrl("locations/{$entry->id}.json")
];
},
];
},
]
];