Created
April 1, 2020 13:22
-
-
Save riccardolardi/b5fbb07ebf87c4e0c0515b61af3bd3bd to your computer and use it in GitHub Desktop.
elementapi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use craft\elements\Entry; | |
use craft\helpers\UrlHelper; | |
return [ | |
'endpoints' => [ | |
'acts.json' => function() { | |
return [ | |
'pretty' => true, | |
'paginate' => false, | |
'elementType' => Entry::class, | |
'criteria' => ['section' => 'acts'], | |
'transformer' => function(Entry $entry) { | |
$images = []; | |
foreach ($entry->actImages->all() as $image) { | |
$images[] = $image; | |
} | |
return [ | |
'title' => $entry->title, | |
'description' => $entry->actDescription, | |
'link' => $entry->actLink, | |
'images' => $images | |
]; | |
} | |
]; | |
} | |
] | |
]; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment