/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransportFactory.php
48 строк
1 KB
Alexander M. Turek
Merge branch '5.4' into 6.0
21 сен 2021, 23:58
21 сен 2021, 23:58
0895c36
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Notifier\Bridge\GoogleChat; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; use Symfony\Component\Notifier\Transport\AbstractTransportFactory; use Symfony\Component\Notifier\Transport\Dsn; /** * @author Jérôme Tamarelle <jerome@tamarelle.net> */ final class GoogleChatTransportFactory extends AbstractTransportFactory { /** * @param Dsn $dsn Format: googlechat://<key>:<token>@default/<space>?thread_key=<thread> */ public function create(Dsn $dsn): GoogleChatTransport { $scheme = $dsn->getScheme(); if ('googlechat' !== $scheme) { throw new UnsupportedSchemeException($dsn, 'googlechat', $this->getSupportedSchemes()); } $space = explode('/', $dsn->getPath())[1]; $accessKey = $this->getUser($dsn); $accessToken = $this->getPassword($dsn); $threadKey = $dsn->getOption('thread_key'); $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); $port = $dsn->getPort(); return (new GoogleChatTransport($space, $accessKey, $accessToken, $threadKey, $this->client, $this->dispatcher))->setHost($host)->setPort($port); } protected function getSupportedSchemes(): array { return ['googlechat']; } }