1 | <?php |
||
2 | |||
3 | namespace kalanis\kw_notify\examples; |
||
4 | |||
5 | /// in bootstrap: |
||
6 | |||
7 | \kalanis\kw_notify\Notification::init( |
||
8 | new \kalanis\kw_notify\Extend\StackName( |
||
9 | new \kalanis\kw_notify\Stack( |
||
10 | new \kalanis\kw_input\Simplified\SessionAdapter() // access sessions in object |
||
0 ignored issues
–
show
|
|||
11 | ), 'kwnotif_' |
||
12 | ) |
||
13 | ); |
||
14 | |||
15 | /// then in extra files: |
||
16 | |||
17 | use kalanis\kw_notify\Interfaces\INotify; |
||
18 | use kalanis\kw_notify\Notification; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * Class Notify |
||
23 | * @package kalanis\kw_notify\examples |
||
24 | * Example of notifications - usage in some controller |
||
25 | */ |
||
26 | class Notify |
||
27 | { |
||
28 | protected static $cssClasses = [ |
||
29 | INotify::TARGET_ERROR => 'alert-box-danger', |
||
30 | INotify::TARGET_WARNING => 'alert-box-warning', |
||
31 | INotify::TARGET_SUCCESS => 'alert-box-success', |
||
32 | INotify::TARGET_INFO => 'alert-box-info', |
||
33 | ]; |
||
34 | |||
35 | public function output(): string |
||
36 | { |
||
37 | $tmpl = new Template(); |
||
38 | $notifications = []; |
||
39 | if (Notification::getNotify()) { |
||
40 | foreach (static::$cssClasses as $type => $cssClass) { |
||
41 | foreach (Notification::getNotify()->get($type) as $message) { |
||
42 | $notifications[] = $tmpl->reset()->setData(Lang::get($type), $message, $cssClass)->render(); |
||
0 ignored issues
–
show
The type
kalanis\kw_notify\examples\Lang was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
43 | } |
||
44 | // clear displayed |
||
45 | Notification::getNotify()->reset($type); |
||
46 | } |
||
47 | } |
||
48 | return implode('', $notifications); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Class Template |
||
55 | * @package kalanis\kw_notify\examples |
||
56 | */ |
||
57 | class Template extends ATemplate |
||
0 ignored issues
–
show
The type
kalanis\kw_notify\examples\ATemplate was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
58 | { |
||
59 | protected $moduleName = 'Notify'; |
||
60 | protected $templateName = 'template'; |
||
61 | |||
62 | protected function fillInputs(): void |
||
63 | { |
||
64 | $this->addInput('{CONTENT_CLASS}'); |
||
65 | $this->addInput('{BOLD_TEXT}'); |
||
66 | $this->addInput('{CONTENT_TEXT}'); |
||
67 | } |
||
68 | |||
69 | public function setData(string $type, string $message, string $class = ''): self |
||
70 | { |
||
71 | $this->updateItem('{BOLD_TEXT}', $type); |
||
72 | $this->updateItem('{CONTENT_TEXT}', $message); |
||
73 | $this->updateItem('{CONTENT_CLASS}', $class); |
||
74 | return $this; |
||
75 | } |
||
76 | } |
||
77 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths