Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
  • Loading branch information
alexmerlin committed May 3, 2024
1 parent 4594059 commit a80415a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
54 changes: 24 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ The flash messenger is a convenient way to add data to the session and get it ba
## Installation

Run the following command in your project folder
```bash
$ composer require dotkernel/dot-flashmessenger
```

composer require dotkernel/dot-flashmessenger

This will also install `laminas/laminas-session` as session handling is based on this library.
Next, merge the `ConfigProvider` to your application's configuration

## Configuration

```php
return [
'dot_flashmessenger' => [
'namespace' => 'flash messages session namespace name'
],
];
```
return [
'dot_flashmessenger' => [
'namespace' => 'flash messages session namespace name'
],
];

Sets the session namespace to use for all flash messages and data

Expand All @@ -47,34 +44,31 @@ If following the installation step, you'll already have a FlashMessenger service
Just inject this service in you classes, wherever you need flash messages.

##### Getting the service in a factory

Check failure on line 46 in README.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (README Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Heading levels should only increment by one level at a time [Expected: h3; Actual: h5]

Check failure on line 46 in README.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (README Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Heading levels should only increment by one level at a time [Expected: h3; Actual: h5]
```php
$container->get(FlashMessengerInterface::class);
```

$container->get(FlashMessengerInterface::class);

##### Using the flash messenger service

To add and retrieve text messages
```php
$this->flashMessenger->addMessage('error', 'This is a error flash message');

//on the next request you can get all messages from a namespace, or all messages from all namespaces if namespace is omitted
$this->flashMessenger->getMessages('error');
```
$this->flashMessenger->addMessage('error', 'This is a error flash message');

//on the next request you can get all messages from a namespace, or all messages from all namespaces if namespace is omitted
$this->flashMessenger->getMessages('error');

Adding general data, not just messages, has a different method for that, accepting data as key/value pairs
```php
$this->flashMessenger->addData('myData', $someData);

//next request
$this->flashMessenger->getData('myData');
```
$this->flashMessenger->addData('myData', $someData);

// next request
$this->flashMessenger->getData('myData');

There are also some predefined namespaces, along with shortcuts to add a message in the predefined namespaces
```php
FlashMessengerInterface::ERROR_NAMESPACE
FlashMessengerInterface::WARNING_NAMESPACE
FlashMessengerInterface::INFO_NAMESPACE
FlashMessengerInterface::SUCCESS_NAMESPACE
```

FlashMessengerInterface::ERROR_NAMESPACE
FlashMessengerInterface::WARNING_NAMESPACE
FlashMessengerInterface::INFO_NAMESPACE
FlashMessengerInterface::SUCCESS_NAMESPACE

```php

Check failure on line 73 in README.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (README Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Code block style [Expected: indented; Actual: fenced]

Check failure on line 73 in README.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (README Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Code block style [Expected: indented; Actual: fenced]
/**
Expand All @@ -101,7 +95,7 @@ public function addSuccess($success);

## FlashMessengerRenderer

A class that is able to parse the content of the flash messenger service in an HTML format.
A class that is able to parse the content of the flash messenger service in an HTML format.
It uses the TemplateInterface to parse a partial, sending to the partial template the messages, the service and the renderer itself.
There are also a twig extension provided in [dot-twigrenderer](https://github.com/dotkernel/dot-twigrenderer), for easy parsing of messages blocks.

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ A flash message, or session message is a piece of text data that survives one re

This library accepts session data as well, not just string messages, with the same behaviour.

The flash messenger is a convenient way to add data to the session and get it back on the next request without bothering with setting and clearing the data manually.
The flash messenger is a convenient way to add data to the session and get it back on the next request without bothering with setting and clearing the data manually.
2 changes: 1 addition & 1 deletion docs/book/v3/renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Partial template example:
{% endif %}
{% endfor %}
{% endif %}
```
```
1 change: 1 addition & 0 deletions docs/book/v3/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ If following the installation step, you'll already have a FlashMessenger service
Just inject this service in you classes, wherever you need flash messages.

### Using the flash messenger service

Check failure on line 6 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Heading levels should only increment by one level at a time [Expected: h2; Actual: h3]

Check failure on line 6 in docs/book/v3/usage.md

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Documentation Linting [8.1, latest], ubuntu-latest, laminas/laminas-continuous-integra...

Heading levels should only increment by one level at a time [Expected: h2; Actual: h3]

To add and retrieve text messages

```php
Expand Down

0 comments on commit a80415a

Please sign in to comment.