fix event dispatcher and call the storage service

This commit is contained in:
Khoubza Younes
2020-12-06 04:03:14 +01:00
parent df1ba5aaad
commit 8bdb9c3ac1
7 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ final class NotifyServiceProvider extends ServiceProvider
public function provides()
{
return array(
'notify.producer',
'flasher.factory',
);
}
+1 -1
View File
@@ -4,7 +4,7 @@ return array(
'default' => 'toastr',
'scripts' => array(
'/vendor/php-flasher/flasher/assets/js/notify.js'
'/vendor/php-flasher/flasher/assets/js/flasher.js'
),
'styles' => array(
+36 -36
View File
@@ -36,7 +36,7 @@ class Laravel implements ServiceProviderInterface
{
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
$provider->publishes(array($source => config_path('notify.php')), 'config');
$provider->publishes(array($source => config_path('flasher.php')), 'config');
$provider->mergeConfigFrom($source, 'notify');
}
@@ -48,7 +48,7 @@ class Laravel implements ServiceProviderInterface
public function registerNotifyServices()
{
$this->app->singleton('notify.config', function (Application $app) {
$this->app->singleton('flasher.config', function (Application $app) {
return new Config($app['config'], '.');
});
@@ -57,80 +57,80 @@ class Laravel implements ServiceProviderInterface
public function registerCommonServices()
{
$this->app->singleton('notify.producer', function (Application $app) {
return new Flasher($app['notify.config']);
$this->app->singleton('flasher.factory', function (Application $app) {
return new Flasher($app['flasher.config']);
});
$this->app->singleton('notify.storage', function (Application $app) {
$this->app->singleton('flasher.storage', function (Application $app) {
return new Storage($app['session']);
});
$this->app->singleton('notify.filter', function (Application $app) {
return new FilterManager($app['notify.config']);
$this->app->singleton('flasher.filter', function (Application $app) {
return new FilterManager($app['flasher.config']);
});
$this->app->singleton('notify.renderer', function (Application $app) {
return new RendererManager($app['notify.config']);
$this->app->singleton('flasher.renderer', function (Application $app) {
return new RendererManager($app['flasher.config']);
});
$this->app->singleton('notify.presenter', function (Application $app) {
$this->app->singleton('flasher.presenter', function (Application $app) {
return new PresenterManager();
});
$this->app->singleton('notify.presenter.html', function (Application $app) {
return new HtmlPresenter($app['notify.config'], $app['notify.storage'], $app['notify.filter'], $app['notify.renderer']);
$this->app->singleton('flasher.presenter.html', function (Application $app) {
return new HtmlPresenter($app['flasher.config'], $app['flasher.storage'], $app['flasher.filter'], $app['flasher.renderer']);
});
$this->app->singleton('notify.presenter.json', function (Application $app) {
return new JsonPresenter($app['notify.config'], $app['notify.storage'], $app['notify.filter'], $app['notify.renderer']);
$this->app->singleton('flasher.presenter.json', function (Application $app) {
return new JsonPresenter($app['flasher.config'], $app['flasher.storage'], $app['flasher.filter'], $app['flasher.renderer']);
});
$this->app->singleton('notify.filter_builder', function (Application $app) {
$this->app->singleton('flasher.filter_builder', function (Application $app) {
return new FilterBuilder();
});
$this->app->singleton('notify.filter.default', function (Application $app) {
return new DefaultFilter($app['notify.filter_builder']);
$this->app->singleton('flasher.filter.default', function (Application $app) {
return new DefaultFilter($app['flasher.filter_builder']);
});
$this->app->singleton('notify.middleware', function (Application $app) {
return new MiddlewareManager($app['notify.config']);
$this->app->singleton('flasher.middleware', function (Application $app) {
return new MiddlewareManager($app['flasher.config']);
});
$this->app->extend('notify.presenter', function (PresenterManager $manager, Container $app) {
$manager->addDriver('html', $app['notify.presenter.html']);
$this->app->extend('flasher.presenter', function (PresenterManager $manager, Container $app) {
$manager->addDriver('html', $app['flasher.presenter.html']);
return $manager;
});
$this->app->extend('notify.presenter', function (PresenterManager $manager, Container $app) {
$manager->addDriver('json', $app['notify.presenter.json']);
$this->app->extend('flasher.presenter', function (PresenterManager $manager, Container $app) {
$manager->addDriver('json', $app['flasher.presenter.json']);
return $manager;
});
$this->app->extend('notify.filter', function (FilterManager $manager, Container $app) {
$manager->addDriver('default', $app['notify.filter.default']);
$this->app->extend('flasher.filter', function (FilterManager $manager, Container $app) {
$manager->addDriver('default', $app['flasher.filter.default']);
return $manager;
});
$this->app->alias('notify.config', 'Flasher\Laravel\Config\Config');
$this->app->alias('notify.producer', 'Flasher\Prime\Flasher');
$this->app->alias('notify.presenter', 'Flasher\Prime\Presenter\PresenterManager');
$this->app->alias('notify.middleware', 'Flasher\Prime\Middleware\MiddlewareManager');
$this->app->alias('notify.storage', 'Flasher\Laravel\Storage\Storage');
$this->app->alias('notify.filter', 'Flasher\Prime\Filter\FilterManager');
$this->app->alias('notify.presenter.html', 'Flasher\Prime\Presenter\Adapter\HtmlPresenter');
$this->app->alias('notify.presenter.json', 'Flasher\Prime\Presenter\Adapter\JsonPresenter');
$this->app->alias('notify.filter_builder', 'Flasher\Prime\Filter\FilterBuilder');
$this->app->alias('notify.filter.default', 'Flasher\Prime\Filter\DefaultFilter');
$this->app->alias('flasher.config', 'Flasher\Laravel\Config\Config');
$this->app->alias('flasher.factory', 'Flasher\Prime\Flasher');
$this->app->alias('flasher.presenter', 'Flasher\Prime\Presenter\PresenterManager');
$this->app->alias('flasher.middleware', 'Flasher\Prime\Middleware\MiddlewareManager');
$this->app->alias('flasher.storage', 'Flasher\Laravel\Storage\Storage');
$this->app->alias('flasher.filter', 'Flasher\Prime\Filter\FilterManager');
$this->app->alias('flasher.presenter.html', 'Flasher\Prime\Presenter\Adapter\HtmlPresenter');
$this->app->alias('flasher.presenter.json', 'Flasher\Prime\Presenter\Adapter\JsonPresenter');
$this->app->alias('flasher.filter_builder', 'Flasher\Prime\Filter\FilterBuilder');
$this->app->alias('flasher.filter.default', 'Flasher\Prime\Filter\DefaultFilter');
}
public function registerBladeDirectives()
{
Blade::directive('notify_render', function ($criteria = null) {
return "<?php echo app('notify.presenter.html')->render($criteria); ?>";
return "<?php echo app('flasher.presenter.html')->render($criteria); ?>";
});
}
}
+2 -2
View File
@@ -26,7 +26,7 @@ final class Laravel4 extends Laravel
public function registerNotifyServices()
{
$this->app->singleton('notify.config', function (Application $app) {
$this->app->singleton('flasher.config', function (Application $app) {
return new Config($app['config'], '::');
});
@@ -38,7 +38,7 @@ final class Laravel4 extends Laravel
Blade::extend(function ($view, $compiler) {
$pattern = $compiler->createPlainMatcher('notify_render(.*)');
return preg_replace($pattern, '$1<?php echo app(\'notify.presenter.html\')->render($2); ?>', $view);
return preg_replace($pattern, '$1<?php echo app(\'flasher.presenter.html\')->render($2); ?>', $view);
});
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ final class Laravel50 extends Laravel
Blade::extend(function ($view, $compiler) {
$pattern = $compiler->createPlainMatcher('notify_render(.*)');
return preg_replace($pattern, '$1<?php echo app(\'notify.presenter.html\')->render($2); ?>', $view);
return preg_replace($pattern, '$1<?php echo app(\'flasher.presenter.html\')->render($2); ?>', $view);
});
}
}
+3 -3
View File
@@ -8,12 +8,12 @@ class NotifyServiceProviderTest extends TestCase
{
public function test_notify_service_exists()
{
$this->assertTrue($this->app->bound('notify.producer'));
$this->assertTrue($this->app->bound('flasher.factory'));
}
public function test_notify_manager_get_config()
{
$notify = $this->app->make('notify.producer');
$notify = $this->app->make('flasher.factory');
$reflection = new \ReflectionClass(get_class($notify));
$config = $reflection->getProperty('config');
@@ -27,6 +27,6 @@ class NotifyServiceProviderTest extends TestCase
/** @var BladeCompiler $blade */
$blade = $this->app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
$this->assertEquals("<?php echo app('notify.presenter.html')->render(); ?>", $blade->compileString('@notify_render'));
$this->assertEquals("<?php echo app('flasher.presenter.html')->render(); ?>", $blade->compileString('@notify_render'));
}
}
+2 -2
View File
@@ -13,9 +13,9 @@ if (!function_exists('notify')) {
function notify($message = null, $type = 'success', $title = '', array $options = array(), array $stamps = array())
{
if (is_null($message) && 0 === func_num_args()) {
return app('notify.producer');
return app('flasher.factory');
}
return app('notify.producer')->render($type, $message, $title, $options, $stamps);
return app('flasher.factory')->render($type, $message, $title, $options, $stamps);
}
}