Move RSS into its own controller

This commit is contained in:
James Brooks
2014-11-27 14:52:36 +00:00
parent 252b6a1126
commit 6d5ad36ae9
2 changed files with 28 additions and 23 deletions

View File

@@ -0,0 +1,27 @@
<?php
class RSSController extends Controller {
public function feedAction() {
$feed = RSS::feed('2.0', 'UTF-8');
$feed->channel([
'title' => Setting::get('app_name'),
'description' => 'Status Feed',
'link' => Setting::get('app_domain'),
]);
Incident::get()->map(function($incident) use ($feed) {
$feed->item([
'title' => $incident->name,
'message' => $incident->message,
'component' => $incident->parent->name,
'status' => $incident->humanStatus,
'created_at' => $incident->created_at,
'updated_at' => $incident->updated_at
]);
});
return Response::make($feed, 200, [
'Content-Type' => 'text/xml'
]);
}
}

View File

@@ -21,26 +21,4 @@
Route::get('/auth/logout', 'AuthController@logoutAction');
});
Route::get('/rss', function() {
$feed = RSS::feed('2.0', 'UTF-8');
$feed->channel([
'title' => Setting::get('app_name'),
'description' => 'Status Feed',
'link' => Setting::get('app_domain'),
]);
Incident::get()->map(function($incident) use ($feed) {
$feed->item([
'title' => $incident->name,
'message' => $incident->message,
'component' => $incident->parent->name,
'status' => $incident->humanStatus,
'created_at' => $incident->created_at,
'updated_at' => $incident->updated_at
]);
});
return Response::make($feed, 200, [
'Content-Type' => 'text/xml'
]);
});
Route::get('/rss', 'RSSController@feedAction');