mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 23:17:47 +01:00
update namespaces
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-laravel",
|
||||
"description": "Laravel Flasher package for php-flasher/flasher",
|
||||
"description": "Laravel adapter for php-flasher/flasher library",
|
||||
"keywords": [
|
||||
"yoeunes",
|
||||
"notify",
|
||||
"flasher",
|
||||
"php",
|
||||
"laravel",
|
||||
"symfony",
|
||||
@@ -31,13 +32,12 @@
|
||||
"illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0",
|
||||
"php-flasher/flasher": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0",
|
||||
"orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\": ""
|
||||
"Flasher\\Laravel\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"helpers.php"
|
||||
@@ -52,10 +52,7 @@
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Flasher\\Laravel\\FlasherServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Flasher": "Flasher\\Laravel\\Facades\\Flasher"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
+1
-2
@@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Flasher\Notyf\Laravel\ServiceProvider\ServiceProviderManager;
|
||||
|
||||
class NotifyNotyfServiceProvider extends ServiceProvider
|
||||
class FlasherNotyfServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
@@ -31,7 +31,6 @@ class NotifyNotyfServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory',
|
||||
'flasher.factory.notyf',
|
||||
'flasher.renderer.notyf',
|
||||
);
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider;
|
||||
use Flasher\Notyf\Prime\Factory\NotyfProducer;
|
||||
use Flasher\Notyf\Prime\Renderer\NotyfRenderer;
|
||||
use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider;
|
||||
use Flasher\Notyf\Prime\NotyfFactory;
|
||||
use Flasher\Notyf\Prime\NotyfRenderer;
|
||||
use Flasher\Prime\Flasher;
|
||||
use Flasher\Prime\Renderer\RendererManager;
|
||||
use Illuminate\Container\Container;
|
||||
@@ -24,36 +24,36 @@ class Laravel implements ServiceProviderInterface
|
||||
return $this->app instanceof Application;
|
||||
}
|
||||
|
||||
public function publishConfig(NotifyNotyfServiceProvider $provider)
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('notify_notyf.php')), 'config');
|
||||
$provider->publishes(array($source => config_path('flasher_notyf.php')), 'config');
|
||||
|
||||
$provider->mergeConfigFrom($source, 'notify_notyf');
|
||||
$provider->mergeConfigFrom($source, 'flasher_notyf');
|
||||
}
|
||||
|
||||
public function registerNotifyNotyfServices()
|
||||
public function registerServices()
|
||||
{
|
||||
$this->app->singleton('flasher.factory.notyf', function (Container $app) {
|
||||
return new NotyfProducer($app['flasher.storage'], $app['flasher.middleware']);
|
||||
return new NotyfFactory($app['flasher.event_dispatcher']);
|
||||
});
|
||||
|
||||
$this->app->singleton('flasher.renderer.notyf', function (Container $app) {
|
||||
return new NotyfRenderer($app['flasher.config']);
|
||||
});
|
||||
|
||||
$this->app->alias('flasher.factory.notyf', 'Flasher\Notyf\Prime\Factory\NotyfProducer');
|
||||
$this->app->alias('flasher.renderer.notyf', 'Flasher\Notyf\Prime\Renderer\NotyfRenderer');
|
||||
$this->app->alias('flasher.factory.notyf', 'Flasher\Notyf\Prime\NotyfFactory');
|
||||
$this->app->alias('flasher.renderer.notyf', 'Flasher\Notyf\Prime\NotyfRenderer');
|
||||
|
||||
$this->app->extend('flasher.factory', function (Flasher $manager, Container $app) {
|
||||
$manager->addDriver('notyf', $app['flasher.factory.notyf']);
|
||||
$this->app->extend('flasher', function (Flasher $manager, Container $app) {
|
||||
$manager->addDriver($app['flasher.factory.notyf']);
|
||||
|
||||
return $manager;
|
||||
});
|
||||
|
||||
$this->app->extend('flasher.renderer', function (RendererManager $manager, Container $app) {
|
||||
$manager->addDriver('notyf', $app['flasher.renderer.notyf']);
|
||||
$this->app->extend('flasher.renderer_manager', function (RendererManager $manager, Container $app) {
|
||||
$manager->addDriver($app['flasher.renderer.notyf']);
|
||||
|
||||
return $manager;
|
||||
});
|
||||
@@ -61,10 +61,10 @@ class Laravel implements ServiceProviderInterface
|
||||
|
||||
public function mergeConfigFromNotyf()
|
||||
{
|
||||
$notifyConfig = $this->app['config']->get('flasher.adapters.notyf', array());
|
||||
$flasherConfig = $this->app['config']->get('flasher.adapters.notyf', array());
|
||||
|
||||
$notyfConfig = $this->app['config']->get('notify_notyf', array());
|
||||
$notyfConfig = $this->app['config']->get('flasher_notyf', array());
|
||||
|
||||
$this->app['config']->set('flasher.adapters.notyf', array_merge($notyfConfig, $notifyConfig));
|
||||
$this->app['config']->set('flasher.adapters.notyf', array_merge($notyfConfig, $flasherConfig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider;
|
||||
|
||||
final class Laravel4 extends Laravel
|
||||
{
|
||||
@@ -12,17 +12,17 @@ final class Laravel4 extends Laravel
|
||||
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
|
||||
}
|
||||
|
||||
public function publishConfig(NotifyNotyfServiceProvider $provider)
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-laravel-notyf', 'notify_notyf', __DIR__.'/../../../resources');
|
||||
$provider->package('php-flasher/flasher-laravel-notyf', 'flasher_notyf', __DIR__.'/../../../resources');
|
||||
}
|
||||
|
||||
public function mergeConfigFromNotyf()
|
||||
{
|
||||
$notifyConfig = $this->app['config']->get('notify::config.adapters.notyf', array());
|
||||
$flasherConfig = $this->app['config']->get('flasher::config.adapters.notyf', array());
|
||||
|
||||
$notyfConfig = $this->app['config']->get('notify_notyf::config', array());
|
||||
$notyfConfig = $this->app['config']->get('flasher_notyf::config', array());
|
||||
|
||||
$this->app['config']->set('notify::config.adapters.notyf', array_merge($notyfConfig, $notifyConfig));
|
||||
$this->app['config']->set('flasher::config.adapters.notyf', array_merge($notyfConfig, $flasherConfig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider;
|
||||
use Laravel\Lumen\Application;
|
||||
use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider;
|
||||
|
||||
final class Lumen extends Laravel
|
||||
{
|
||||
@@ -12,12 +12,12 @@ final class Lumen extends Laravel
|
||||
return $this->app instanceof Application;
|
||||
}
|
||||
|
||||
public function publishConfig(NotifyNotyfServiceProvider $provider)
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||
|
||||
$this->app->configure('notify_notyf');
|
||||
$this->app->configure('flasher_notyf');
|
||||
|
||||
$provider->mergeConfigFrom($source, 'notify_notyf');
|
||||
$provider->mergeConfigFrom($source, 'flasher_notyf');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider;
|
||||
use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider;
|
||||
|
||||
interface ServiceProviderInterface
|
||||
{
|
||||
public function shouldBeUsed();
|
||||
|
||||
public function publishConfig(NotifyNotyfServiceProvider $provider);
|
||||
public function publishConfig(FlasherNotyfServiceProvider $provider);
|
||||
|
||||
public function registerNotifyNotyfServices();
|
||||
public function registerServices();
|
||||
|
||||
public function mergeConfigFromNotyf();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\ServiceProvider;
|
||||
|
||||
use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider;
|
||||
use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider;
|
||||
use Flasher\Notyf\Laravel\ServiceProvider\Providers\ServiceProviderInterface;
|
||||
|
||||
final class ServiceProviderManager
|
||||
@@ -20,7 +20,7 @@ final class ServiceProviderManager
|
||||
|
||||
private $notifyServiceProvider;
|
||||
|
||||
public function __construct(NotifyNotyfServiceProvider $notifyServiceProvider)
|
||||
public function __construct(FlasherNotyfServiceProvider $notifyServiceProvider)
|
||||
{
|
||||
$this->notifyServiceProvider = $notifyServiceProvider;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ final class ServiceProviderManager
|
||||
public function register()
|
||||
{
|
||||
$provider = $this->resolveServiceProvider();
|
||||
$provider->registerNotifyNotyfServices();
|
||||
$provider->registerServices();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Flasher\Notyf\Laravel\Tests;
|
||||
|
||||
class NotifyNotyfServiceProviderTest extends TestCase
|
||||
final class NotifyNotyfServiceProviderTest extends TestCase
|
||||
{
|
||||
public function testContainerContainNotifyServices()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Orchestra\Testbench\TestCase as Orchestra;
|
||||
|
||||
class TestCase extends Orchestra
|
||||
final class TestCase extends Orchestra
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-laravel-notyf",
|
||||
"description": "Laravel Flasher adapter package for php-flasher/flasher-notyf",
|
||||
"name": "php-flasher/flasher-notyf-laravel",
|
||||
"description": "Laravel adapter for php-flasher/flasher-notyf library",
|
||||
"keywords": [
|
||||
"yoeunes",
|
||||
"notify",
|
||||
@@ -29,27 +29,26 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-laravel": "^1.0.4",
|
||||
"php-flasher/flasher-notyf": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0",
|
||||
"orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
|
||||
"php-flasher/flasher-laravel": "dev-main",
|
||||
"php-flasher/flasher-notyf": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\Notyf\\": "src/"
|
||||
"Flasher\\Notyf\\Laravel\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\Notyf\\Tests\\": "tests/"
|
||||
"Flasher\\Notyf\\Laravel\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Flasher\\Laravel\\Notyf\Flasher\PrimeNotyfServiceProvider"
|
||||
"Flasher\\Notyf\\Laravel\\FlasherNotyfServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Notyf\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\Notification;
|
||||
|
||||
final class Notyf extends Notification
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Notyf\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\NotificationBuilder;
|
||||
|
||||
/**
|
||||
* @method Pnotify getNotification()
|
||||
*/
|
||||
final class NotyfBuilder extends NotificationBuilder
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Notyf\Prime;
|
||||
|
||||
use Flasher\Prime\Factory\AbstractFactory;
|
||||
|
||||
final class NotyfFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotification()
|
||||
{
|
||||
return new Pnotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotificationBuilder()
|
||||
{
|
||||
return new PnotifyBuilder($this->getEventDispatcher(), $this->createNotification(), 'notyf');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'notyf'));
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Notyf\Prime\Renderer;
|
||||
namespace Flasher\Notyf\Prime;
|
||||
|
||||
use Flasher\Prime\Config\ConfigInterface;
|
||||
use Flasher\Prime\Envelope;
|
||||
use Flasher\Prime\Renderer\HasGlobalOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasScriptsInterface;
|
||||
use Flasher\Prime\Renderer\HasStylesInterface;
|
||||
use Flasher\Prime\Renderer\RendererInterface;
|
||||
|
||||
class NotyfRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasGlobalOptionsInterface
|
||||
final class NotyfRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasOptionsInterface
|
||||
{
|
||||
/**
|
||||
* @var ConfigInterface
|
||||
@@ -44,8 +44,7 @@ class NotyfRenderer implements RendererInterface, HasScriptsInterface, HasStyles
|
||||
*/
|
||||
public function render(Envelope $envelope)
|
||||
{
|
||||
$context = $envelope->getContext();
|
||||
$options = isset($context['options']) ? $context['options'] : array();
|
||||
$options = $envelope->getOptions();
|
||||
|
||||
$options['message'] = $envelope->getMessage();
|
||||
$options['type'] = $envelope->getType();
|
||||
@@ -73,4 +72,14 @@ class NotyfRenderer implements RendererInterface, HasScriptsInterface, HasStyles
|
||||
{
|
||||
return sprintf('if ("undefined" === typeof notyf) { var notyf = new Notyf(%s); }', json_encode($this->options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'notyf', 'Flasher\Notyf\Prime\NotyfFactory',
|
||||
'Flasher\Notyf\Prime\Pnotify'
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Notyf\Prime\Factory;
|
||||
|
||||
final class NotyfProducer extends \Flasher\Prime\AbstractFlasher
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRenderer()
|
||||
{
|
||||
return 'notyf';
|
||||
}
|
||||
}
|
||||
@@ -26,19 +26,19 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Notyf\\": "src"
|
||||
"Flasher\\Notyf\\Prime\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Notyf\\Tests\\": "tests/"
|
||||
"Flasher\\Notyf\\prime\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('notify_notyf');
|
||||
$treeBuilder = new TreeBuilder('flasher_notyf');
|
||||
|
||||
if (\method_exists($treeBuilder, 'getRootNode')) {
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
} else {
|
||||
// BC layer for symfony/config 4.1 and older
|
||||
$rootNode = $treeBuilder->root('notify_notyf');
|
||||
$rootNode = $treeBuilder->root('flasher_notyf');
|
||||
}
|
||||
|
||||
$rootNode
|
||||
|
||||
+5
-7
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
final class NotifyNotyfExtension extends Extension implements PrependExtensionInterface
|
||||
final class FlasherNotyfExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -18,7 +18,7 @@ final class NotifyNotyfExtension extends Extension implements PrependExtensionIn
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('config.yaml');
|
||||
|
||||
$configuration = new Configuration();
|
||||
$this->processConfiguration($configuration, $configs);
|
||||
@@ -29,16 +29,14 @@ final class NotifyNotyfExtension extends Extension implements PrependExtensionIn
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasExtension('notify')) {
|
||||
throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered');
|
||||
if (!$container->hasExtension('flasher')) {
|
||||
throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered');
|
||||
}
|
||||
|
||||
$configs = $container->getExtensionConfig($this->getAlias());
|
||||
$config = $this->processConfiguration(new Configuration(), $configs);
|
||||
|
||||
$notifyConfig = $container->getExtensionConfig('notify');
|
||||
|
||||
$container->prependExtensionConfig('notify', array(
|
||||
$container->prependExtensionConfig('flasher', array(
|
||||
'adapters' => array(
|
||||
'notyf' => $config,
|
||||
),
|
||||
@@ -4,6 +4,6 @@ namespace Flasher\Notyf\Symfony;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class NotifyNotyfBundle extends Bundle
|
||||
class FlasherNotyfBundle extends Bundle
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
flasher.factory.notyf:
|
||||
parent: 'flasher.abstract_factory'
|
||||
class: Flasher\Notyf\Prime\NotyfProducer
|
||||
tags:
|
||||
- { name: 'flasher.factory' }
|
||||
|
||||
flasher.renderer.notyf:
|
||||
class: Flasher\Notyf\Prime\NotyfRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer' }
|
||||
|
||||
Flasher\Notyf\Prime\NotyfProducer: '@flasher.factory.notyf'
|
||||
Flasher\Notyf\Prime\NotyfRenderer: '@flasher.renderer.notyf'
|
||||
@@ -1,16 +0,0 @@
|
||||
services:
|
||||
flasher.factory.notyf:
|
||||
parent: 'flasher.factory.abstract'
|
||||
class: Flasher\Notyf\Prime\Factory\NotyfProducer
|
||||
tags:
|
||||
- { name: 'flasher.factory', alias: 'notyf' }
|
||||
|
||||
flasher.renderer.notyf:
|
||||
class: Flasher\Notyf\Prime\Renderer\NotyfRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer', alias: 'notyf' }
|
||||
|
||||
Flasher\Notyf\Prime\Factory\NotyfProducer: '@flasher.factory.notyf'
|
||||
Flasher\Notyf\Prime\Renderer\NotyfRenderer: '@flasher.renderer.notyf'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-symfony-notyf",
|
||||
"name": "php-flasher/flasher-notyf-symfony",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Symfony Flasher adapter for Sweet Alert 2 library for php-flasher/flasher-symfony",
|
||||
"keywords": [
|
||||
@@ -31,20 +31,20 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-symfony": "^1.0",
|
||||
"php-flasher/flasher-notyf": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher-symfony": "dev-main",
|
||||
"php-flasher/flasher-notyf": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\Notyf\\": "src/"
|
||||
"Flasher\\Notyf\\Symfony\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\Notyf\\Tests\\": "tests/"
|
||||
"Flasher\\Notyf\\Symfony\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-laravel-pnotify",
|
||||
"name": "php-flasher/flasher-pnotify-laravel",
|
||||
"description": "Laravel Flasher adapter package for php-flasher/flasher-pnotify",
|
||||
"keywords": [
|
||||
"yoeunes",
|
||||
@@ -28,27 +28,26 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-laravel": "^1.0.4",
|
||||
"php-flasher/flasher-pnotify": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0",
|
||||
"orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
|
||||
"php-flasher/flasher-laravel": "dev-main",
|
||||
"php-flasher/flasher-pnotify": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\Pnotify\\": "src/"
|
||||
"Flasher\\Pnotify\\Laravel\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\Pnotify\\Tests\\": "tests/"
|
||||
"Flasher\\Pnotify\\Laravel\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Flasher\\Laravel\\Pnotify\Flasher\PrimePnotifyServiceProvider"
|
||||
"Flasher\\Pnotify\\Laravel\\NotifyPnotifyServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Pnotify\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\Notification;
|
||||
|
||||
final class Pnotify extends Notification
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Pnotify\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\NotificationBuilder;
|
||||
|
||||
/**
|
||||
* @method Pnotify getNotification()
|
||||
*/
|
||||
final class PnotifyBuilder extends NotificationBuilder
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\Pnotify\Prime;
|
||||
|
||||
use Flasher\Prime\Factory\AbstractFactory;
|
||||
|
||||
final class PnotifyFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotification()
|
||||
{
|
||||
return new Pnotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotificationBuilder()
|
||||
{
|
||||
return new PnotifyBuilder($this->getEventDispatcher(), $this->createNotification(), 'pnotify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'pnotify'));
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\PFlasher\Prime\Renderer;
|
||||
namespace Flasher\PFlasher\Prime;
|
||||
|
||||
use Flasher\Prime\Config\ConfigInterface;
|
||||
use Flasher\Prime\Envelope;
|
||||
use Flasher\Prime\Renderer\HasGlobalOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasScriptsInterface;
|
||||
use Flasher\Prime\Renderer\HasStylesInterface;
|
||||
use Flasher\Prime\Renderer\RendererInterface;
|
||||
|
||||
class PnotifyRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasGlobalOptionsInterface
|
||||
class PnotifyRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasOptionsInterface
|
||||
{
|
||||
/**
|
||||
* @var ConfigInterface
|
||||
@@ -44,10 +44,8 @@ class PnotifyRenderer implements RendererInterface, HasScriptsInterface, HasStyl
|
||||
*/
|
||||
public function render(Envelope $envelope)
|
||||
{
|
||||
$context = $envelope->getContext();
|
||||
$options = isset($context['options']) ? $context['options'] : array();
|
||||
$options = $envelope->getOptions();
|
||||
|
||||
$options['title'] = " " . $envelope->getTitle();
|
||||
$options['text'] = $envelope->getMessage();
|
||||
$options['type'] = $envelope->getType();
|
||||
|
||||
@@ -74,4 +72,12 @@ class PnotifyRenderer implements RendererInterface, HasScriptsInterface, HasStyl
|
||||
{
|
||||
return sprintf('PNotify.defaults = %s;', json_encode($this->options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'pnotify', 'Flasher\Pnotify\Prime\PnotifyFactory', 'Flasher\Pnotify\Prime\Pnotify'));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\PFlasher\Prime\TestsProducer;
|
||||
|
||||
use Flasher\Prime\AbstractFlasher;
|
||||
|
||||
final class PnotifyProducer extends AbstractFlasher
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRenderer()
|
||||
{
|
||||
return 'pnotify';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function warning($message, $title = '', $context = array(), array $stamps = array())
|
||||
{
|
||||
return $this->render('notice', $message, $title, $context, $stamps);
|
||||
}
|
||||
}
|
||||
@@ -26,19 +26,19 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Pnotify\\": "src"
|
||||
"Flasher\\Pnotify\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Pnotify\\Tests\\": "tests/"
|
||||
"Flasher\\Pnotify\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('notify_pnotify');
|
||||
$treeBuilder = new TreeBuilder('flasher_pnotify');
|
||||
|
||||
if (\method_exists($treeBuilder, 'getRootNode')) {
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
} else {
|
||||
// BC layer for symfony/config 4.1 and older
|
||||
$rootNode = $treeBuilder->root('notify_pnotify');
|
||||
$rootNode = $treeBuilder->root('flasher_pnotify');
|
||||
}
|
||||
|
||||
$rootNode
|
||||
|
||||
+5
-5
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
final class NotifyPnotifyExtension extends Extension implements PrependExtensionInterface
|
||||
final class FlasherPnotifyExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -18,7 +18,7 @@ final class NotifyPnotifyExtension extends Extension implements PrependExtension
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('config.yaml');
|
||||
|
||||
$configuration = new Configuration();
|
||||
$this->processConfiguration($configuration, $configs);
|
||||
@@ -29,14 +29,14 @@ final class NotifyPnotifyExtension extends Extension implements PrependExtension
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasExtension('notify')) {
|
||||
throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered');
|
||||
if (!$container->hasExtension('flasher')) {
|
||||
throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered');
|
||||
}
|
||||
|
||||
$configs = $container->getExtensionConfig($this->getAlias());
|
||||
$config = $this->processConfiguration(new Configuration(), $configs);
|
||||
|
||||
$container->prependExtensionConfig('notify', array(
|
||||
$container->prependExtensionConfig('flasher', array(
|
||||
'adapters' => array(
|
||||
'pnotify' => $config,
|
||||
),
|
||||
+1
-1
@@ -4,6 +4,6 @@ namespace Flasher\Pnotify\Symfony;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class NotifyPnotifyBundle extends Bundle
|
||||
class FlasherPnotifyBundle extends Bundle
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
flasher.factory.pnotify:
|
||||
parent: 'flasher.abstract_factory'
|
||||
class: Flasher\Pnotify\Prime\PnotifyFactory
|
||||
tags:
|
||||
- { name: 'flasher.factory' }
|
||||
|
||||
flasher.renderer.pnotify:
|
||||
class: Flasher\PFlasher\Prime\PnotifyRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer' }
|
||||
|
||||
Flasher\PFlasher\Prime\PnotifyFactory: '@flasher.factory.pnotify'
|
||||
Flasher\PFlasher\Prime\PnotifyRenderer: '@flasher.renderer.pnotify'
|
||||
@@ -1,16 +0,0 @@
|
||||
services:
|
||||
flasher.factory.pnotify:
|
||||
parent: 'flasher.factory.abstract'
|
||||
class: Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer
|
||||
tags:
|
||||
- { name: 'flasher.factory', alias: 'pnotify' }
|
||||
|
||||
flasher.renderer.pnotify:
|
||||
class: Flasher\PFlasher\Prime\Renderer\PnotifyRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer', alias: 'pnotify' }
|
||||
|
||||
Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer: '@flasher.factory.pnotify'
|
||||
Flasher\PFlasher\Prime\Renderer\PnotifyRenderer: '@flasher.renderer.pnotify'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-symfony-pnotify",
|
||||
"name": "php-flasher/flasher-pnotify-symfony",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Symfony Flasher adapter for pnotify.js library for php-flasher/flasher-symfony",
|
||||
"keywords": [
|
||||
@@ -29,20 +29,20 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-symfony": "^1.0",
|
||||
"php-flasher/flasher-pnotify": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher-symfony": "dev-main",
|
||||
"php-flasher/flasher-pnotify": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\Pnotify\\": "src/"
|
||||
"Flasher\\Pnotify\\Symfony\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\Pnotify\\Tests\\": "tests/"
|
||||
"Flasher\\Pnotify\\Symfony\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=4.8.36"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Prime\\": "",
|
||||
|
||||
+1
-2
@@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Flasher\SweetAlert\Laravel\ServiceProvider\ServiceProviderManager;
|
||||
|
||||
class NotifySweetAlertServiceProvider extends ServiceProvider
|
||||
final class FlasherSweetAlertServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
@@ -31,7 +31,6 @@ class NotifySweetAlertServiceProvider extends ServiceProvider
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'flasher.factory',
|
||||
'flasher.factory.sweet_alert',
|
||||
'flasher.renderer.sweet_alert',
|
||||
);
|
||||
@@ -4,9 +4,9 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\Prime\Flasher;
|
||||
use Flasher\Prime\Renderer\RendererManager;
|
||||
use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider;
|
||||
use Flasher\SweetAlert\Prime\Factory\SweetAlertProducer;
|
||||
use Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer;
|
||||
use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider;
|
||||
use Flasher\SweetAlert\Prime\SweetAlertFactory;
|
||||
use Flasher\SweetAlert\Prime\SweetAlertRenderer;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
@@ -24,36 +24,36 @@ class Laravel implements ServiceProviderInterface
|
||||
return $this->app instanceof Application;
|
||||
}
|
||||
|
||||
public function publishConfig(NotifySweetAlertServiceProvider $provider)
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||
|
||||
$provider->publishes(array($source => config_path('notify_sweet_alert.php')), 'config');
|
||||
$provider->publishes(array($source => config_path('flasher_sweet_alert.php')), 'config');
|
||||
|
||||
$provider->mergeConfigFrom($source, 'notify_sweet_alert');
|
||||
$provider->mergeConfigFrom($source, 'flasher_sweet_alert');
|
||||
}
|
||||
|
||||
public function registerNotifySweetAlertServices()
|
||||
public function registerServices()
|
||||
{
|
||||
$this->app->singleton('flasher.factory.sweet_alert', function (Container $app) {
|
||||
return new SweetAlertProducer($app['flasher.storage'], $app['flasher.middleware']);
|
||||
return new SweetAlertFactory($app['flasher.event_dispatcher']);
|
||||
});
|
||||
|
||||
$this->app->singleton('flasher.renderer.sweet_alert', function (Container $app) {
|
||||
return new SweetAlertRenderer($app['flasher.config']);
|
||||
});
|
||||
|
||||
$this->app->alias('flasher.factory.sweet_alert', 'Flasher\SweetAlert\Prime\Factory\SweetAlertProducer');
|
||||
$this->app->alias('flasher.renderer.sweet_alert', 'Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer');
|
||||
$this->app->alias('flasher.factory.sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertFactory');
|
||||
$this->app->alias('flasher.renderer.sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertRenderer');
|
||||
|
||||
$this->app->extend('flasher.factory', function (Flasher $manager, Container $app) {
|
||||
$manager->addDriver('sweet_alert', $app['flasher.factory.sweet_alert']);
|
||||
$this->app->extend('flasher', function (Flasher $manager, Container $app) {
|
||||
$manager->addDriver($app['flasher.factory.sweet_alert']);
|
||||
|
||||
return $manager;
|
||||
});
|
||||
|
||||
$this->app->extend('flasher.renderer', function (RendererManager $manager, Container $app) {
|
||||
$manager->addDriver('sweet_alert', $app['flasher.renderer.sweet_alert']);
|
||||
$this->app->extend('flasher.renderer_manager', function (RendererManager $manager, Container $app) {
|
||||
$manager->addDriver($app['flasher.renderer.sweet_alert']);
|
||||
|
||||
return $manager;
|
||||
});
|
||||
@@ -63,7 +63,7 @@ class Laravel implements ServiceProviderInterface
|
||||
{
|
||||
$notifyConfig = $this->app['config']->get('flasher.adapters.sweet_alert', array());
|
||||
|
||||
$sweetAlertConfig = $this->app['config']->get('notify_sweet_alert', array());
|
||||
$sweetAlertConfig = $this->app['config']->get('flasher_sweet_alert', array());
|
||||
|
||||
$this->app['config']->set('flasher.adapters.sweet_alert', array_merge($sweetAlertConfig, $notifyConfig));
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider;
|
||||
|
||||
final class Laravel4 extends Laravel
|
||||
{
|
||||
@@ -12,17 +12,17 @@ final class Laravel4 extends Laravel
|
||||
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
|
||||
}
|
||||
|
||||
public function publishConfig(NotifySweetAlertServiceProvider $provider)
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$provider->package('php-flasher/flasher-laravel-sweet_alert', 'notify_sweet_alert', __DIR__.'/../../../resources');
|
||||
$provider->package('php-flasher/flasher-laravel-sweet_alert', 'flasher_sweet_alert', __DIR__.'/../../../resources');
|
||||
}
|
||||
|
||||
public function mergeConfigFromSweetAlert()
|
||||
{
|
||||
$notifyConfig = $this->app['config']->get('notify::config.adapters.sweet_alert', array());
|
||||
$flasherConfig = $this->app['config']->get('flasher::config.adapters.sweet_alert', array());
|
||||
|
||||
$sweet_alertConfig = $this->app['config']->get('notify_sweet_alert::config', array());
|
||||
$sweetAlertConfig = $this->app['config']->get('flasher_sweet_alert::config', array());
|
||||
|
||||
$this->app['config']->set('notify::config.adapters.sweet_alert', array_merge($sweet_alertConfig, $notifyConfig));
|
||||
$this->app['config']->set('flasher::config.adapters.sweet_alert', array_merge($sweetAlertConfig, $flasherConfig));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider;
|
||||
use Laravel\Lumen\Application;
|
||||
use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider;
|
||||
|
||||
final class Lumen extends Laravel
|
||||
{
|
||||
@@ -12,12 +12,12 @@ final class Lumen extends Laravel
|
||||
return $this->app instanceof Application;
|
||||
}
|
||||
|
||||
public function publishConfig(NotifySweetAlertServiceProvider $provider)
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider)
|
||||
{
|
||||
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||
|
||||
$this->app->configure('notify_sweet_alert');
|
||||
$this->app->configure('flasher_sweet_alert');
|
||||
|
||||
$provider->mergeConfigFrom($source, 'notify_sweet_alert');
|
||||
$provider->mergeConfigFrom($source, 'flasher_sweet_alert');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers;
|
||||
|
||||
use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider;
|
||||
use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider;
|
||||
|
||||
interface ServiceProviderInterface
|
||||
{
|
||||
public function shouldBeUsed();
|
||||
|
||||
public function publishConfig(NotifySweetAlertServiceProvider $provider);
|
||||
public function publishConfig(FlasherSweetAlertServiceProvider $provider);
|
||||
|
||||
public function registerNotifySweetAlertServices();
|
||||
public function registerServices();
|
||||
|
||||
public function mergeConfigFromSweetAlert();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Flasher\SweetAlert\Laravel\ServiceProvider;
|
||||
|
||||
use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider;
|
||||
use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider;
|
||||
use Flasher\SweetAlert\Laravel\ServiceProvider\Providers\ServiceProviderInterface;
|
||||
|
||||
final class ServiceProviderManager
|
||||
@@ -20,7 +20,7 @@ final class ServiceProviderManager
|
||||
|
||||
private $notifyServiceProvider;
|
||||
|
||||
public function __construct(NotifySweetAlertServiceProvider $notifyServiceProvider)
|
||||
public function __construct(FlasherSweetAlertServiceProvider $notifyServiceProvider)
|
||||
{
|
||||
$this->notifyServiceProvider = $notifyServiceProvider;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ final class ServiceProviderManager
|
||||
public function register()
|
||||
{
|
||||
$provider = $this->resolveServiceProvider();
|
||||
$provider->registerNotifySweetAlertServices();
|
||||
$provider->registerServices();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-laravel-sweet-alert",
|
||||
"name": "php-flasher/flasher-sweet-alert-laravel",
|
||||
"description": "Laravel Flasher adapter package for php-flasher/flasher-sweet-alert",
|
||||
"keywords": [
|
||||
"yoeunes",
|
||||
@@ -29,27 +29,26 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-laravel": "^1.0.4",
|
||||
"php-flasher/flasher-sweet-alert": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0",
|
||||
"orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
|
||||
"php-flasher/flasher-laravel": "dev-main",
|
||||
"php-flasher/flasher-sweet-alert": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\SweetAlert\\": "src/"
|
||||
"Flasher\\Laravel\\SweetAlert\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Laravel\\SweetAlert\\Tests\\": "tests/"
|
||||
"Flasher\\Laravel\\SweetAlert\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Flasher\\Laravel\\SweetAlert\Flasher\PrimeSweetAlertServiceProvider"
|
||||
"Flasher\\SweetAlert\\Laravel\\FlasherSweetAlertServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\SweetAlert\Prime\Factory;
|
||||
|
||||
final class SweetAlertProducer extends \Flasher\Prime\AbstractFlasher
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRenderer()
|
||||
{
|
||||
return 'sweet_alert';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function question($message, $title = '', $context = array(), array $stamps = array())
|
||||
{
|
||||
return $this->render('question', $message, $title, $context, $stamps);
|
||||
}
|
||||
|
||||
public function image($title = '', $message = '', $imageUrl, $imageWidth = 400, $imageHeight = 200, $imageAlt = '', array $stamps = array())
|
||||
{
|
||||
$context['options']['title'] = $title;
|
||||
$context['options']['text'] = $message;
|
||||
$context['options']['imageUrl'] = $imageUrl;
|
||||
$context['options']['imageWidth'] = $imageWidth;
|
||||
$context['options']['imageHeight'] = $imageHeight;
|
||||
|
||||
if (!is_null($imageAlt)) {
|
||||
$context['options']['imageAlt'] = $imageAlt;
|
||||
} else {
|
||||
$context['options']['imageAlt'] = $title;
|
||||
}
|
||||
|
||||
$context['options']['animation'] = false;
|
||||
|
||||
return $this->render('info', $message, $title, $context, $stamps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\SweetAlert\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\Notification;
|
||||
|
||||
final class SweetAlert extends Notification
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\SweetAlert\Prime;
|
||||
|
||||
use Flasher\Prime\Notification\NotificationBuilder;
|
||||
|
||||
final class SweetAlertBuilder extends NotificationBuilder
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\SweetAlert\Prime;
|
||||
|
||||
use Flasher\Prime\Factory\AbstractFactory;
|
||||
|
||||
final class SweetAlertFactory extends AbstractFactory
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotification()
|
||||
{
|
||||
return new SweetAlert();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function createNotificationBuilder()
|
||||
{
|
||||
return new SweetAlertBuilder($this->getEventDispatcher(), $this->createNotification(), 'sweet_alert');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'sweet_alert'));
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Flasher\SweetAlert\Prime\Renderer;
|
||||
namespace Flasher\SweetAlert\Prime;
|
||||
|
||||
use Flasher\Prime\Config\ConfigInterface;
|
||||
use Flasher\Prime\Envelope;
|
||||
use Flasher\Prime\Renderer\HasGlobalOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasOptionsInterface;
|
||||
use Flasher\Prime\Renderer\HasScriptsInterface;
|
||||
use Flasher\Prime\Renderer\HasStylesInterface;
|
||||
use Flasher\Prime\Renderer\RendererInterface;
|
||||
|
||||
class SweetAlertRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasGlobalOptionsInterface
|
||||
final class SweetAlertRenderer implements RendererInterface, HasScriptsInterface, HasStylesInterface, HasOptionsInterface
|
||||
{
|
||||
/**
|
||||
* @var \Flasher\Prime\Config\ConfigInterface
|
||||
@@ -44,10 +44,8 @@ class SweetAlertRenderer implements RendererInterface, HasScriptsInterface, HasS
|
||||
*/
|
||||
public function render(Envelope $envelope)
|
||||
{
|
||||
$context = $envelope->getContext();
|
||||
$options = isset($context['options']) ? $context['options'] : array();
|
||||
$options = $envelope->getOptions();
|
||||
|
||||
$options['title'] = " " . $envelope->getTitle();
|
||||
$options['text'] = $envelope->getMessage();
|
||||
$options['icon'] = $envelope->getType();
|
||||
|
||||
@@ -78,4 +76,12 @@ class SweetAlertRenderer implements RendererInterface, HasScriptsInterface, HasS
|
||||
{
|
||||
return sprintf('var SwalToast = Swal.mixin(%s);', json_encode($this->options));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($name = null, array $context = array())
|
||||
{
|
||||
return in_array($name, array(__CLASS__, 'sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertFactory', 'Flasher\SweetAlert\Prime\SweetAlert'));
|
||||
}
|
||||
}
|
||||
@@ -25,19 +25,19 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\SweetAlert\\": "src"
|
||||
"Flasher\\SweetAlert\\prime\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\SweetAlert\\Tests\\": "tests/"
|
||||
"Flasher\\SweetAlert\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('notify_sweet-alert');
|
||||
$treeBuilder = new TreeBuilder('flasher_sweet-alert');
|
||||
|
||||
if (\method_exists($treeBuilder, 'getRootNode')) {
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
} else {
|
||||
// BC layer for symfony/config 4.1 and older
|
||||
$rootNode = $treeBuilder->root('notify_sweet_alert');
|
||||
$rootNode = $treeBuilder->root('flasher_sweet_alert');
|
||||
}
|
||||
|
||||
$rootNode
|
||||
|
||||
+5
-9
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
final class NotifySweetAlertExtension extends Extension implements PrependExtensionInterface
|
||||
final class FlasherSweetAlertExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -18,7 +18,7 @@ final class NotifySweetAlertExtension extends Extension implements PrependExtens
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('config.yaml');
|
||||
|
||||
$configuration = new Configuration();
|
||||
$this->processConfiguration($configuration, $configs);
|
||||
@@ -29,18 +29,14 @@ final class NotifySweetAlertExtension extends Extension implements PrependExtens
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasExtension('notify')) {
|
||||
throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered');
|
||||
if (!$container->hasExtension('flasher')) {
|
||||
throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered');
|
||||
}
|
||||
|
||||
$configs = $container->getExtensionConfig($this->getAlias());
|
||||
$config = $this->processConfiguration(new Configuration(), $configs);
|
||||
|
||||
$notifyConfig = $container->getExtensionConfig('notify');
|
||||
|
||||
// dd($notifyConfig);
|
||||
|
||||
$container->prependExtensionConfig('notify', array(
|
||||
$container->prependExtensionConfig('flasher', array(
|
||||
'adapters' => array(
|
||||
'sweet_alert' => $config,
|
||||
),
|
||||
+1
-1
@@ -4,6 +4,6 @@ namespace Flasher\SweetAlert\Symfony;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class NotifySweetAlertBundle extends Bundle
|
||||
class FlasherSweetAlertBundle extends Bundle
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
flasher.factory.sweet_alert:
|
||||
parent: 'flasher.factory.abstract'
|
||||
class: Flasher\SweetAlert\Prime\SweetAlertFactory
|
||||
tags:
|
||||
- { name: 'flasher.factory' }
|
||||
|
||||
flasher.renderer.sweet_alert:
|
||||
class: Flasher\SweetAlert\Prime\SweetAlertRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer' }
|
||||
|
||||
Flasher\SweetAlert\Prime\SweetAlertFactory: '@flasher.factory.sweet_alert'
|
||||
Flasher\SweetAlert\Prime\SweetAlertRenderer: '@flasher.renderer.sweet_alert'
|
||||
@@ -1,16 +0,0 @@
|
||||
services:
|
||||
flasher.factory.sweet_alert:
|
||||
parent: 'flasher.factory.abstract'
|
||||
class: Flasher\SweetAlert\Prime\Factory\SweetAlertProducer
|
||||
tags:
|
||||
- { name: 'flasher.factory', alias: 'sweet_alert' }
|
||||
|
||||
flasher.renderer.sweet_alert:
|
||||
class: Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer
|
||||
arguments:
|
||||
- '@flasher.config'
|
||||
tags:
|
||||
- { name: 'flasher.renderer', alias: 'sweet_alert' }
|
||||
|
||||
Flasher\SweetAlert\Prime\Factory\SweetAlertProducer: '@flasher.factory.sweet_alert'
|
||||
Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer: '@flasher.renderer.sweet_alert'
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "php-flasher/flasher-symfony-sweet-alert",
|
||||
"name": "php-flasher/flasher-sweet-alert-symfony",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Symfony Flasher adapter for Sweet Alert 2 library for php-flasher/flasher-symfony",
|
||||
"keywords": [
|
||||
@@ -30,20 +30,20 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher-symfony": "^1.0",
|
||||
"php-flasher/flasher-sweet-alert": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
"php-flasher/flasher-symfony": "dev-main",
|
||||
"php-flasher/flasher-sweet-alert": "dev-main"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\SweetAlert\\": "src/"
|
||||
"Flasher\\SweetAlert\\Symfony\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\SweetAlert\\Tests\\": "tests/"
|
||||
"Flasher\\SweetAlert\\Symfony\\Tests\\": "Tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -44,7 +44,10 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Symfony\\": ""
|
||||
"Flasher\\Symfony\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Flasher\Toastr\Laravel\ServiceProvider\ServiceProviderManager;
|
||||
|
||||
class FlasherToastrServiceProvider extends ServiceProvider
|
||||
final class FlasherToastrServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
|
||||
@@ -31,13 +31,12 @@
|
||||
"php-flasher/flasher-laravel": "dev-main",
|
||||
"php-flasher/flasher-toastr": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0",
|
||||
"orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Toastr\\Laravel\\": ""
|
||||
"Flasher\\Toastr\\Laravel\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
"php": ">=5.3",
|
||||
"php-flasher/flasher": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Toastr\\": ""
|
||||
"Flasher\\Toastr\\Prime\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
"php-flasher/flasher-symfony": "dev-main",
|
||||
"php-flasher/flasher-toastr": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.8.36"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Flasher\\Toastr\\Symfony\\": ""
|
||||
"Flasher\\Toastr\\Symfony\\": "",
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
||||
Reference in New Issue
Block a user