@@ -94,7 +94,7 @@ public function __construct( $deployDir ) {
9494
9595 // Slim does not natively understand being behind a proxy
9696 // If not corrected template links created via siteUrl() may use the wrong
97- // protocol (http instead of https).
97+ // Protocol (http instead of https).
9898 if ( getenv ( 'HTTP_X_FORWARDED_PROTO ' ) ) {
9999 $ proto = getenv ( 'HTTP_X_FORWARDED_PROTO ' );
100100 $ this ->slim ->environment ['slim.url_scheme ' ] = $ proto ;
@@ -163,6 +163,15 @@ protected function configureIoc() {
163163 );
164164 } );
165165
166+ $ container ->singleton ( 'reportsDao ' , function ( $ c ) {
167+ $ uid = $ c ->authManager ->getUserId ();
168+ return new \Wikimedia \IEGReview \Dao \Reports (
169+ $ c ->settings ['db.dsn ' ],
170+ $ c ->settings ['db.user ' ], $ c ->settings ['db.pass ' ],
171+ $ uid , $ c ->log
172+ );
173+ } );
174+
166175 $ container ->singleton ( 'authManager ' , function ( $ c ) {
167176 return new \Wikimedia \IEGReview \AuthManager ( $ c ->usersDao );
168177 } );
@@ -217,7 +226,7 @@ protected function configureIoc() {
217226 * Configure view behavior.
218227 */
219228 protected function configureView () {
220- // configure twig views
229+ // Configure twig views
221230 $ view = $ this ->slim ->view ;
222231
223232 $ view ->parserOptions = array (
@@ -229,7 +238,7 @@ protected function configureView() {
229238 'autoescape ' => true ,
230239 );
231240
232- // install twig parser extensions
241+ // Install twig parser extensions
233242 $ view ->parserExtensions = array (
234243 new \Slim \Views \TwigExtension (),
235244 new TwigExtension (),
@@ -239,7 +248,7 @@ protected function configureView() {
239248 ),
240249 );
241250
242- // set default view data
251+ // Set default view data
243252 $ view ->replace ( array (
244253 'app ' => $ this ->slim ,
245254 'i18nCtx ' => $ this ->slim ->i18nContext ,
@@ -276,7 +285,7 @@ protected function configureRoutes() {
276285
277286 'require-user ' => function () use ( $ slim ) {
278287 if ( $ slim ->authManager ->isAnonymous () ) {
279- // redirect to login form if not authenticated
288+ // Redirect to login form if not authenticated
280289 if ( $ slim ->request ->isGet () ) {
281290 $ uri = $ slim ->request ->getUrl () . $ slim ->request ->getPath ();
282291 $ qs = \Wikimedia \IEGReview \Form::qsMerge ();
@@ -298,7 +307,7 @@ protected function configureRoutes() {
298307
299308 'require-admin ' => function () use ( $ slim ) {
300309 if ( !$ slim ->authManager ->isAdmin () ) {
301- // redirect to login form if not an admin user
310+ // Redirect to login form if not an admin user
302311 if ( $ slim ->request ->isGet () ) {
303312 $ uri = $ slim ->request ->getUrl () . $ slim ->request ->getPath ();
304313 $ qs = \Wikimedia \IEGReview \Form::qsMerge ();
@@ -346,7 +355,7 @@ function () use ( $slim ) {
346355
347356 } );
348357
349- // routes for authenticated users
358+ // Routes for authenticated users
350359 $ slim ->group ( '/user/ ' ,
351360 $ middleware ['must-revalidate ' ], $ middleware ['require-user ' ],
352361 function () use ( $ slim , $ middleware ) {
@@ -367,7 +376,7 @@ function () use ( $slim, $middleware ) {
367376 } )->name ( 'user_changepassword_post ' );
368377 } );
369378
370- // routes for proposals
379+ // Routes for proposals
371380 $ slim ->group ( '/proposals/ ' ,
372381 $ middleware ['must-revalidate ' ], $ middleware ['require-user ' ],
373382 function () use ( $ slim , $ middleware ) {
@@ -412,7 +421,17 @@ function () use ( $slim, $middleware ) {
412421 $ page ->setReviewsDao ( $ slim ->reviewsDao );
413422 $ page ( $ id );
414423 } )->name ( 'proposals_view ' );
424+ } );
415425
426+ // Routes for reports
427+ $ slim ->group ( '/reports/ ' ,
428+ $ middleware ['must-revalidate ' ], $ middleware ['require-user ' ],
429+ function () use ( $ slim , $ middleware ) {
430+ $ slim ->get ( 'aggregated ' , function () use ( $ slim ) {
431+ $ page = new Controllers \Reports \Aggregated ( $ slim );
432+ $ page ->setDao ( $ slim ->reportsDao );
433+ $ page ();
434+ } )->name ( 'reports_aggregated ' );
416435 } );
417436
418437 $ slim ->group ( '/admin/ ' ,
@@ -457,5 +476,4 @@ public static function template( $slim, $name, $routeName = null ) {
457476 $ slim ->render ( "{$ name }.html " );
458477 } )->name ( $ routeName );
459478 }
460-
461- } //end App
479+ }
0 commit comments