1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Controller; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Controller\AbstractController as BaseController; |
15
|
|
|
use WBW\Bundle\CoreBundle\Event\NotificationEvent; |
16
|
|
|
use WBW\Bundle\CoreBundle\Notification\NotificationFactory; |
17
|
|
|
use WBW\Bundle\CoreBundle\WBWCoreEvents; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Abstract controller. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\BootstrapBundle\Controller |
24
|
|
|
* @abstract |
25
|
|
|
*/ |
26
|
|
|
abstract class AbstractController extends BaseController { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Notify "danger". |
30
|
|
|
* |
31
|
|
|
* @param string $content The content. |
32
|
|
|
* @return NotificationEvent Returns the event. |
33
|
|
|
*/ |
34
|
|
|
protected function notifyDanger(string $content): NotificationEvent { |
35
|
|
|
$notification = NotificationFactory::newDangerNotification($content); |
36
|
|
|
return $this->notify(WBWCoreEvents::NOTIFICATION_DANGER, $notification); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Notify "info". |
41
|
|
|
* |
42
|
|
|
* @param string $content The content. |
43
|
|
|
* @return NotificationEvent Returns the event. |
44
|
|
|
*/ |
45
|
|
|
protected function notifyInfo(string $content): NotificationEvent { |
46
|
|
|
$notification = NotificationFactory::newInfoNotification($content); |
47
|
|
|
return $this->notify(WBWCoreEvents::NOTIFICATION_INFO, $notification); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Notify "success". |
52
|
|
|
* |
53
|
|
|
* @param string $content The content. |
54
|
|
|
* @return NotificationEvent Returns the event. |
55
|
|
|
*/ |
56
|
|
|
protected function notifySuccess(string $content): NotificationEvent { |
57
|
|
|
$notification = NotificationFactory::newSuccessNotification($content); |
58
|
|
|
return $this->notify(WBWCoreEvents::NOTIFICATION_SUCCESS, $notification); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Notify "warning". |
63
|
|
|
* |
64
|
|
|
* @param string $content The content. |
65
|
|
|
* @return NotificationEvent Returns the event. |
66
|
|
|
*/ |
67
|
|
|
protected function notifyWarning(string $content): NotificationEvent { |
68
|
|
|
$notification = NotificationFactory::newWarningNotification($content); |
69
|
|
|
return $this->notify(WBWCoreEvents::NOTIFICATION_WARNING, $notification); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|