Skip to content

Commit 7941e3e

Browse files
committed
Работа с flashBag.
1 parent 6f91575 commit 7941e3e

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

configs/notifier.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363

6464
->set('request_stack', RequestStack::class)
6565
->call('push', [service('module_request')])
66+
->public()
67+
6668
->set('event_dispatcher', EventDispatcher::class)
6769

6870
->set('module_request', Request::class)

lib/DI/Services.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
1616
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
19+
use Symfony\Component\HttpFoundation\Session\Session;
1820
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
1921
use Symfony\Component\Mailer\Mailer;
2022
use Symfony\Component\Notifier\Recipient\Recipient;
@@ -176,6 +178,21 @@ class_exists(\Twig\Environment::class)
176178
static::$container->compile(true);
177179
}
178180

181+
/**
182+
* Flashes.
183+
*
184+
* @return FlashBagInterface
185+
* @throws Exception
186+
*/
187+
public static function getFlashBag() : FlashBagInterface
188+
{
189+
$container = static::getInstance();
190+
/** @var Session $session */
191+
$session = $container->get('session_instance');
192+
193+
return $session->getFlashBag();
194+
}
195+
179196
/**
180197
* Обработка классов как сервисов из битриксового конфига. Раздел services.
181198
*

readme.MD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,12 @@ return [
176176
Параметр (массив) `compile_container_envs` указывает окружения, при которых необходимо кэшировать контейнер.
177177

178178
Пока простая логика: `$_ENV["DEBUG"] === true` => окружение `dev`, иначе `prod`.
179+
180+
## Прочее
181+
182+
#### FlashBag
183+
184+
Для обработки отправок в канал `browser`. Два варианта:
185+
186+
- публичный сервис `session_instance` вернет экземпляр сессии, а там есть метод `getFlashBag`.
187+
- хэлпер `\Proklung\Notifier\DI\Services::getFlashBag()`, делающий тоже самое.

0 commit comments

Comments
 (0)