update namespaces

This commit is contained in:
Khoubza Younes
2020-12-06 17:29:32 +01:00
parent bf4b769e99
commit 94ff72e864
7 changed files with 70 additions and 53 deletions
-41
View File
@@ -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);
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Flasher\SweetAlert\Prime;
use Flasher\Prime\Notification\Notification;
final class SweetAlert extends Notification
{
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Flasher\SweetAlert\Prime;
use Flasher\Prime\Notification\NotificationBuilder;
final class SweetAlertBuilder extends NotificationBuilder
{
}
+32
View File
@@ -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'));
}
}
@@ -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'));
}
}
View File
+6 -6
View File
@@ -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": {