/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Workflow/Event/EventNameTrait.php
61 строка
2 KB
Alexander M. Turek
Prefix all sprintf() calls
20 июн 2024, 18:52
20 июн 2024, 18:52
6ce530c
Код
Авторство
О чём код?
<?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\Workflow\Event; use Symfony\Component\Workflow\Exception\InvalidArgumentException; /** * @author Nicolas Rigaud <squrious@protonmail.com> * * @internal */ trait EventNameTrait { /** * Gets the event name for workflow and transition. * * @throws InvalidArgumentException If $transitionName is provided without $workflowName */ private static function getNameForTransition(?string $workflowName, ?string $transitionName): string { return self::computeName($workflowName, $transitionName); } /** * Gets the event name for workflow and place. * * @throws InvalidArgumentException If $placeName is provided without $workflowName */ private static function getNameForPlace(?string $workflowName, ?string $placeName): string { return self::computeName($workflowName, $placeName); } private static function computeName(?string $workflowName, ?string $transitionOrPlaceName): string { $eventName = strtolower(basename(str_replace('\\', '/', static::class), 'Event')); if (null === $workflowName) { if (null !== $transitionOrPlaceName) { throw new \InvalidArgumentException('Missing workflow name.'); } return \sprintf('workflow.%s', $eventName); } if (null === $transitionOrPlaceName) { return \sprintf('workflow.%s.%s', $workflowName, $eventName); } return \sprintf('workflow.%s.%s.%s', $workflowName, $eventName, $transitionOrPlaceName); } }