Skip to content

Commit a369e72

Browse files
committed
updated readme file
1 parent 5b72633 commit a369e72

1 file changed

Lines changed: 52 additions & 1 deletion

File tree

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
11
# dot-controller-plugin-flashmessenger
2-
Flashmessenger DK controller plugin
2+
3+
Flashmessenger controller plugin for easy access to the flash messenger from any controller.
4+
5+
# Installation
6+
7+
Run the following command in your project root directory
8+
```bash
9+
$ composer require dotkernel/dot-controller-plugin-flashmessenger
10+
```
11+
12+
This will also install packages `dotkernel/dot-controller` and `dotkernel/dot-flashmessenger` as dependencies.
13+
Next, make sure you merge the `ConfigProvider` to your application's configuration in order to register the default dependencies.
14+
15+
## Usage
16+
17+
In any controller, you can access the plugin by calling
18+
```php
19+
$this->flashMessenger()->...
20+
```
21+
22+
The methods defined by this plugin are
23+
```php
24+
$this->flashMessenger()->addMessage($namespace, $value);
25+
```
26+
Adds a session message to at the requested namespace
27+
28+
```php
29+
$this->flashMessenger()->addData($key, $data);
30+
```
31+
Almost the same as the addMessage method, but named differently in order to reserve this function for adding general session data.
32+
33+
There are also some shortcuts to the addMessage method which are using predefined namespaces
34+
```php
35+
$this->flashMessenger()->addError($error);
36+
37+
$this->flashMessenger()->addWarning($message);
38+
39+
$this->flashMessenger()->addInfo($message);
40+
41+
$this->flashMessenger()->addSuccess($message);
42+
```
43+
44+
Also, the getter methods
45+
```php
46+
$this->flashMessenger()->getMessages($namespace = null);
47+
```
48+
Gets all messages under a namespace, or if namespace is not specified it will return all namespaces with all messages
49+
50+
```php
51+
$this->flashMessenger()->getData($key);
52+
```
53+
Gets the data stored at the specified key

0 commit comments

Comments
 (0)