Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e37347b
commit ee67611
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 LoveOrigami | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Getting started with yii2-notification-wrapper | ||
|
||
Yii2-notification-wrapper module renders a message from session flash (with ajax support). All flash messages are displayed | ||
in the sequence they were assigned using setFlash. You can set message as following: | ||
|
||
```php | ||
public function actionIndex(){ | ||
... | ||
\Yii::$app->getSession()->setFlash('error', 'noty1'); | ||
\Yii::$app->getSession()->setFlash('info', 'noty2'); | ||
\Yii::$app->getSession()->setFlash('success', 'noty3'); | ||
\Yii::$app->getSession()->setFlash('warning', 'noty4'); | ||
... | ||
return $this->render('index'); | ||
} | ||
// or in ajax action | ||
|
||
public function actionAjax(){ | ||
... | ||
\Yii::$app->getSession()->setFlash('error', 'ajax-noty1'); | ||
\Yii::$app->getSession()->setFlash('info', 'ajax-noty2'); | ||
\Yii::$app->getSession()->setFlash('success', 'ajax-noty3'); | ||
\Yii::$app->getSession()->setFlash('warning', 'ajax-noty4'); | ||
... | ||
$data = 'Some data to be returned in response to ajax request'; | ||
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||
return $data; | ||
} | ||
``` | ||
|
||
Download | ||
-------- | ||
|
||
Yii2-notification-wrapper can be installed using composer. Run following command to download and | ||
install Yii2-notification-wrapper: | ||
|
||
```bash | ||
composer require "loveorigami/yii2-notification-wrapper": "*" | ||
``` | ||
|
||
Configure application | ||
--------------------- | ||
|
||
Let's start with defining module in our config file (`@common/config/main.php`): | ||
|
||
```php | ||
'modules' => [ | ||
'noty' => [ | ||
'class' => 'lo\modules\noty\Module', | ||
], | ||
], | ||
``` | ||
That's all, now you have module installed and configured. | ||
|
||
Usage | ||
----- | ||
|
||
|
||
Supported libraries | ||
------------------- | ||
|
||
Currently supported libraries are: | ||
|
||
| Library | Constant | Project homepage | | ||
| -------------- | ------------- | ---------------------------------------------- | | ||
| Noty | THEME_NOTY | https://github.com/Shifrin/yii2-noty | | ||
| Toastr | THEME_TOASTR | https://github.com/lavrentiev/yii2-toastr | | ||
|
||
|
||
## License | ||
|
||
Yii2-plugins-system is released under the MIT License. See the bundled [LICENSE.md](LICENSE.md) | ||
for details. |