add CliFlasherInterface for CliNotificationFactory

This commit is contained in:
Khoubza Younes
2021-09-29 17:23:41 +01:00
parent 6d52a98206
commit 257b37de81
9 changed files with 32 additions and 21 deletions
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Flasher\Cli\Prime;
/**
* @mixin CliNotificationBuilder
*/
interface CliFlasherInterface
{
public function render(array $criteria = array(), $presenter = 'html', array $context = array());
}
+17 -4
View File
@@ -3,12 +3,25 @@
namespace Flasher\Cli\Prime; namespace Flasher\Cli\Prime;
use Flasher\Prime\Factory\NotificationFactory; use Flasher\Prime\Factory\NotificationFactory;
use Flasher\Prime\Response\ResponseManagerInterface;
use Flasher\Prime\Storage\StorageManagerInterface;
/** final class CliNotificationFactory extends NotificationFactory implements CliFlasherInterface
* @mixin CliNotificationBuilder
*/
final class CliNotificationFactory extends NotificationFactory
{ {
private $responseManager;
public function __construct(StorageManagerInterface $storageManager, ResponseManagerInterface $responseManager)
{
parent::__construct($storageManager);
$this->responseManager = $responseManager;
}
public function render(array $criteria = array(), $presenter = 'html', array $context = array())
{
return $this->responseManager->render($criteria, $presenter, $context);
}
public function createNotificationBuilder() public function createNotificationBuilder()
{ {
return new CliNotificationBuilder($this->getStorageManager(), new CliNotification(), 'cli'); return new CliNotificationBuilder($this->getStorageManager(), new CliNotification(), 'cli');
@@ -13,6 +13,7 @@ if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
$definition $definition
->setClass('Flasher\Cli\Prime\CliNotificationFactory') ->setClass('Flasher\Cli\Prime\CliNotificationFactory')
->addArgument(new Reference('flasher.response_manager'))
->addTag('flasher.factory', array('alias' => 'cli')); ->addTag('flasher.factory', array('alias' => 'cli'));
$container->setDefinition('flasher.cli', $definition); $container->setDefinition('flasher.cli', $definition);
@@ -69,4 +70,5 @@ $container
if (Bridge::canLoadAliases()) { if (Bridge::canLoadAliases()) {
$container->setAlias('Flasher\Cli\Prime\CliNotificationFactory', 'flasher.cli'); $container->setAlias('Flasher\Cli\Prime\CliNotificationFactory', 'flasher.cli');
$container->setAlias('Flasher\Cli\Prime\CliFlasherInterface', 'Flasher\Cli\Prime\CliNotificationFactory');
} }
-3
View File
@@ -4,9 +4,6 @@ namespace Flasher\Noty\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/**
* @method self livewire(array $context = array())
*/
final class NotyBuilder extends NotificationBuilder final class NotyBuilder extends NotificationBuilder
{ {
/** /**
-3
View File
@@ -4,9 +4,6 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/**
* @method self livewire(array $context = array())
*/
final class NotyfBuilder extends NotificationBuilder final class NotyfBuilder extends NotificationBuilder
{ {
/** /**
-3
View File
@@ -4,9 +4,6 @@ namespace Flasher\Pnotify\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/**
* @method self livewire(array $context = array())
*/
final class PnotifyBuilder extends NotificationBuilder final class PnotifyBuilder extends NotificationBuilder
{ {
public function warning($message = null, array $options = array()) public function warning($message = null, array $options = array())
@@ -6,8 +6,8 @@ use Flasher\Prime\Envelope;
use Flasher\Prime\Stamp\StampInterface; use Flasher\Prime\Stamp\StampInterface;
/** /**
* @method self livewire(array $context = array()) * @method $this livewire(array $context = array())
* @method self desktop(bool $renderImmediately = true) * @method $this desktop(bool $renderImmediately = true)
*/ */
interface NotificationBuilderInterface interface NotificationBuilderInterface
{ {
@@ -4,9 +4,6 @@ namespace Flasher\SweetAlert\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/**
* @method self livewire(array $context = array())
*/
final class SweetAlertBuilder extends NotificationBuilder final class SweetAlertBuilder extends NotificationBuilder
{ {
public function type($type, $message = null, array $options = array()) public function type($type, $message = null, array $options = array())
-3
View File
@@ -4,9 +4,6 @@ namespace Flasher\Toastr\Prime;
use Flasher\Prime\Notification\NotificationBuilder; use Flasher\Prime\Notification\NotificationBuilder;
/**
* @method self livewire(array $context = array())
*/
final class ToastrBuilder extends NotificationBuilder final class ToastrBuilder extends NotificationBuilder
{ {
/** /**