Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 281849b..918655a 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -1,70 +1,74 @@
<?php
namespace Nasqueron\Notifications\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Validation\ValidationException;
+use Illuminate\Session\TokenMismatchException;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Config;
use Raven;
use Exception;
class Handler extends ExceptionHandler {
/**
* A list of the exception types that should not be reported.
*
* @var string[]
*/
protected $dontReport = [
AuthorizationException::class,
CommandNotFoundException::class,
HttpException::class,
ModelNotFoundException::class,
+ TokenMismatchException::class,
ValidationException::class,
];
/**
* Reports or logs an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
*/
public function report(Exception $e) : void {
if (!$this->shouldReport($e)) {
return;
}
if ($this->shouldReportToSentry()) {
$this->reportToSentry($e);
}
- $this->log->error((string)$e);
+ $log = $this->container->make(LoggerInterface::class);
+ $log->error((string)$e);
}
/**
* Determines if the error handler should report to Sentry
*
* @return bool
*/
protected function shouldReportToSentry () : bool {
return Raven::isConfigured() && Config::get('app.env') !== 'testing';
}
/**
* Reports the exception to Sentry
*
* @param Exception $e The exception to report
*/
protected function reportToSentry (Exception $e) : void {
Raven::captureException($e);
}
}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index bbf747b..c8f026a 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -1,30 +1,50 @@
<?php
namespace Nasqueron\Notifications\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
+ * These middleware are run during every request to your application.
+ *
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
- \Nasqueron\Notifications\Http\Middleware\EncryptCookies::class,
- \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
- \Illuminate\Session\Middleware\StartSession::class,
- \Illuminate\View\Middleware\ShareErrorsFromSession::class,
- \Nasqueron\Notifications\Http\Middleware\VerifyCsrfToken::class,
+ ];
+
+ /**
+ * The application's route middleware groups.
+ *
+ * @var array
+ */
+ protected $middlewareGroups = [
+ 'web' => [
+ \Nasqueron\Notifications\Http\Middleware\EncryptCookies::class,
+ \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+ \Illuminate\Session\Middleware\StartSession::class,
+ \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+ \Nasqueron\Notifications\Http\Middleware\VerifyCsrfToken::class,
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ ],
+
+ 'api' => [
+ 'throttle:60,1',
+ 'bindings',
+ ],
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
+ 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 782bb46..a46d0e2 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -1,31 +1,30 @@
<?php
namespace Nasqueron\Notifications\Providers;
use Illuminate\{
Contracts\Events\Dispatcher as DispatcherContract,
Foundation\Support\Providers\EventServiceProvider as ServiceProvider
};
use Config;
class EventServiceProvider extends ServiceProvider {
/**
* Registers all our listeners as subscriber classes
*/
private function subscribeListeners () {
$this->subscribe += Config::get('app.listeners');
}
/**
* Register any other events for your application.
*
- * @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
- public function boot(DispatcherContract $events) {
+ public function boot() {
$this->subscribeListeners();
- parent::boot($events);
+ parent::boot();
}
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 41ac555..3df3dde 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -1,44 +1,43 @@
<?php
namespace Nasqueron\Notifications\Providers;
use Illuminate\{
Routing\Router,
Foundation\Support\Providers\RouteServiceProvider as ServiceProvider
};
class RouteServiceProvider extends ServiceProvider {
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'Nasqueron\Notifications\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
- * @param \Illuminate\Routing\Router $router
* @return void
*/
- public function boot(Router $router) {
+ public function boot() {
//
- parent::boot($router);
+ parent::boot();
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router) {
$router->group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/routes.php');
});
}
}
diff --git a/composer.json b/composer.json
index d62f8ad..8071da8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,60 +1,60 @@
{
"name": "nasqueron/notifications",
"description": "Nasqueron notifications center",
"keywords": [
"nasqueron",
"activemq",
"AMQP",
"notifications"
],
"license": "BSD-2-Clause",
"type": "project",
"require": {
"php": ">=7.1.0",
- "laravel/framework": "5.2.*",
+ "laravel/framework": "5.3.*",
"guzzlehttp/guzzle": "^6.2",
"keruald/dockerhub": "^0.0.3",
"keruald/github": "^0.2.1",
"keruald/broker": "^0.4.1",
"keruald/mailgun": "^0.0.1",
"netresearch/jsonmapper": "^1.1.1",
"sentry/sentry": "^0.13.0"
},
"require-dev": {
"phan/phan": "^0.12.3",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"pdepend/pdepend": "^2.4.1",
"phploc/phploc": "^3.0.1",
"phpmd/phpmd" : "@stable",
- "phpunit/phpunit": "~4.0",
+ "phpunit/phpunit": "~5.4",
"phpspec/phpspec": "~2.1",
"sebastian/phpcpd": "^2.0.4",
"squizlabs/php_codesniffer": "2.*",
"symfony/css-selector": "~3.0",
"symfony/dom-crawler": "~3.0"
},
"autoload": {
"psr-4": {
"Nasqueron\\Notifications\\": "app/",
"Nasqueron\\Notifications\\Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"phpmd": [
"vendor/bin/phpmd app/ xml ruleset.xml"
],
"test": [
"phpunit --no-coverage"
]
},
"config": {
"preferred-install": "dist"
}
}
diff --git a/config/app.php b/config/app.php
index c8c9b15..c7226aa 100644
--- a/config/app.php
+++ b/config/app.php
@@ -1,270 +1,282 @@
<?php
return [
+ /*
+ |--------------------------------------------------------------------------
+ | Application Name
+ |--------------------------------------------------------------------------
+ |
+ | This value is the name of your application. This value is used when the
+ | framework needs to place the application's name in a notification or
+ | any other location as required by the application or its packages.
+ */
+
+ 'name' => 'Notifications',
+
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => 'http://localhost',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
/*
|--------------------------------------------------------------------------
| Features
|--------------------------------------------------------------------------
|
| This array contains the features provided by the notifications center.
|
| It allows to toggle a feature on the fly, with a boolean to enable it.
|
*/
'features' => [
// Enable the API entry point at the /gate URL
'Gate' => true,
// Enable the configuration report entry point at the /config URL
'GetConfig' => true,
// Send a response to inform the caller of the different actions done.
// If disabled, send an empty 200 response instead.
'ActionsReport' => true,
],
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
Nasqueron\Notifications\Providers\AppServiceProvider::class,
Nasqueron\Notifications\Providers\BrokerServiceProvider::class,
Nasqueron\Notifications\Providers\DockerHubServiceProvider::class,
Nasqueron\Notifications\Providers\EventServiceProvider::class,
Nasqueron\Notifications\Providers\MailgunServiceProvider::class,
Nasqueron\Notifications\Providers\PhabricatorAPIServiceProvider::class,
Nasqueron\Notifications\Providers\PhabricatorProjectsMapServiceProvider::class,
Nasqueron\Notifications\Providers\ReportServiceProvider::class,
Nasqueron\Notifications\Providers\RouteServiceProvider::class,
Nasqueron\Notifications\Providers\SentryServiceProvider::class,
Nasqueron\Notifications\Providers\ServicesServiceProvider::class
],
/*
|--------------------------------------------------------------------------
| Events listeners
|--------------------------------------------------------------------------
|
| The events listeners listed here will be automatically loaded on the
| request to your application.
|
*/
'listeners' => [
Nasqueron\Notifications\Listeners\AMQPEventListener::class,
Nasqueron\Notifications\Listeners\DockerHubListener::class,
Nasqueron\Notifications\Listeners\LastPayloadSaver::class,
Nasqueron\Notifications\Listeners\NotificationListener::class,
Nasqueron\Notifications\Listeners\PhabricatorListener::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
/*
* Laravel Framework aliases...
*/
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
/*
* App aliases...
*/
'Broker' => Nasqueron\Notifications\Facades\Broker::class,
'DockerHub' => Nasqueron\Notifications\Facades\DockerHub::class,
'Mailgun' => Nasqueron\Notifications\Facades\Mailgun::class,
'PhabricatorAPI' => Nasqueron\Notifications\Facades\PhabricatorAPI::class,
'ProjectsMap' => Nasqueron\Notifications\Facades\ProjectsMap::class,
'Raven' => Nasqueron\Notifications\Facades\Raven::class,
'Report' => Nasqueron\Notifications\Facades\Report::class,
'Services' => Nasqueron\Notifications\Facades\Services::class,
],
];
diff --git a/tests/Exceptions/HandlerTest.php b/tests/Exceptions/HandlerTest.php
index 07e7e47..895f66c 100644
--- a/tests/Exceptions/HandlerTest.php
+++ b/tests/Exceptions/HandlerTest.php
@@ -1,54 +1,53 @@
<?php
namespace Nasqueron\Notifications\Tests\Exceptions;
use Illuminate\Auth\Access\AuthorizationException;
use Nasqueron\Notifications\Exceptions\Handler;
use Nasqueron\Notifications\Tests\TestCase;
use App;
use Config;
use Mockery;
class HandlerTest extends TestCase {
/**
* Illuminate\Foundation\Exceptions\Handler
*/
private $handler;
/**
* Raven_Client
*/
private $ravenClientMock;
public function setUp () {
parent::setUp();
- $logger = App::make('log');
- $this->handler = new Handler($logger);
+ $this->handler = new Handler(app());
$this->mockRavenClient();
}
protected function mockRavenClient () {
// Inject into our container a mock of Raven_Client
$this->ravenClientMock = Mockery::mock('Raven_Client');
$this->app->instance('raven', $this->ravenClientMock);
// Environment shouldn't be 'testing' and DSN should be defined,
// so Handler::report will call Raven to report to Sentry
Config::set('app.env', 'testing-raven');
Config::set('services.sentry.dsn', 'mock');
}
public function testRavenReport () {
$this->ravenClientMock->shouldReceive('captureException')->once();
$this->handler->report(new \Exception);
}
public function testExceptionInDontReportArray () {
$this->ravenClientMock->shouldReceive('captureException')->never();
$this->handler->report(new AuthorizationException);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Feb 28, 20:37 (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2445785
Default Alt Text
(21 KB)

Event Timeline