Page MenuHomeDevCentral

D177.id.diff
No OneTemporary

D177.id.diff

diff --git a/app/Actions/ActionsReport.php b/app/Actions/ActionsReport.php
--- a/app/Actions/ActionsReport.php
+++ b/app/Actions/ActionsReport.php
@@ -41,8 +41,6 @@
*/
public function __construct () {
$this->created = time();
-
- $this->listenToReports();
}
///
@@ -113,20 +111,4 @@
public function getResponseStatusCode () {
return $this->containsError() ? 503 : 200;
}
-
- ///
- /// Events
- ///
-
- /**
- * Listens to actions to report
- */
- public function listenToReports () {
- Event::listen(
- 'Nasqueron\Notifications\Events\ReportEvent',
- function (ReportEvent $event) {
- $this->addAction($event->action);
- }
- );
- }
}
diff --git a/app/Providers/ReportServiceProvider.php b/app/Providers/ReportServiceProvider.php
--- a/app/Providers/ReportServiceProvider.php
+++ b/app/Providers/ReportServiceProvider.php
@@ -2,21 +2,38 @@
namespace Nasqueron\Notifications\Providers;
+use Illuminate\Events\Dispatcher;
use Illuminate\Support\ServiceProvider;
use Nasqueron\Notifications\Actions\ActionsReport;
+use Nasqueron\Notifications\Events\ReportEvent;
class ReportServiceProvider extends ServiceProvider {
/**
* Registers the application services.
*
* @return void
- *
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function register() {
$this->app->singleton('report', function ($app) {
- return new ActionsReport();
+ $report = new ActionsReport();
+ static::listenToActionsForReport($report, $app['events']);
+ return $report;
});
}
+
+ /**
+ * Listen to actions fired by the application to add to the report
+ *
+ * @param Nasqueron\Notifications\Actions\ActionsReport $report The report to add actions to
+ * @param Illuminate\Events\Dispatcher $events The application events
+ */
+ public static function listenToActionsForReport (ActionsReport $report, Dispatcher $events) {
+ $events->listen(
+ 'Nasqueron\Notifications\Events\ReportEvent',
+ function (ReportEvent $event) use ($report) {
+ $report->addAction($event->action);
+ }
+ );
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 14:29 (2 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260374
Default Alt Text
D177.id.diff (2 KB)

Event Timeline