Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make public api for released talks more useful #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Application/Controller/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function tickets_fahrplan() {
])
->scoped([
'with_default_properties',
'with_encoding_profile_name',
'order_list'
]);

Expand All @@ -48,23 +47,29 @@ public function tickets_released() {
])
->scoped([
'with_recording',
'with_encoding_profile_name',
'with_merged_properties' => [[
'Fahrplan.GUID' => 'fahrplan_guid',
'Record.Language' => 'language',
'Record.Cutdiffseconds' => 'duration',
'YouTube.Url0' => 'youtube_url',
'YouTube.Url1' => 'youtube_url_translated',
'YouTube.Url2' => 'youtube_url_translated_2'
]]
]);
return $this->_respond($tickets);

return $this->_respond($tickets, function($x) { return $x['youtube_url'] !== null; });
}

protected function _respond($data) {
protected function _respond($data, $filter = null) {
if ($data instanceOf Model_Resource) {
$data = $data->toArray();
}


if ($filter) {
$data = array_values(array_filter($data, $filter));
}

if ($this->respondTo('json')) {
$this->Response->setContent(json_encode($data));
return $this->Response;
Expand All @@ -75,4 +80,4 @@ protected function _respond($data) {

}

?>
?>