Skip to content

phil/instant-messenger-bundle

alpha

A messaging handle field with its service, a validation constraint and Twig filters for Symfony.

phil/instant-messenger-bundle brings phil/instant-messenger into a Symfony application. HandleType is two fields that give a Handle: the service, chosen among the accepted ones, and the handle as the person types it. The constraint HandleOfType checks a Handle by its service, and a text by detecting its service among the accepted ones. Twig gets messenger_display, messenger_link and messenger_label. Messages come in English and French.

It is for Symfony applications whose forms collect a way to reach someone: a member's Signal, a shop's WhatsApp, an organiser's Matrix ID. The field asks for the service because handles collide: a user name or a phone number fits several services. The accepted services are named as phil/url-bundle names kinds: null for every international service, an enum class, a case, an EnumSet or a list of these.

Use phil/instant-messenger directly outside Symfony or inside a domain model. The bundle has no column type: a handle is stored as two columns the application maps, the service with its own enum. It wires the library into Symfony Form, Validator and Twig, and adds no rule of its own.

Status

PartState
HandleType: the service chosen among the accepted ones, and the handleImplemented and tested
HandleOfType: a handle, or a text detected, on an accepted serviceImplemented and tested
Twig: messenger_display, messenger_link, messenger_labelImplemented and tested
Messages in English and FrenchImplemented and tested

Documentation

DocumentWhat it covers
InstallationRequirements, installing, registering.
Forms and validationHandleType, HandleOfType, the accepted services, and storing a handle.
TwigThe three filters.
Extension pointsWhat an application implements, configures, replaces or relies on.
TestingHow the bundle is tested.
ReferenceEvery type of the bundle.

Quick start

composer require phil/instant-messenger-bundle
$builder->add('messenger', HandleType::class, ['types' => [KnownMessenger::Signal, KnownMessenger::WhatsApp]]);
{% set link = shop.messenger|messenger_link %}
{% if link %}<a href="{{ link }}">{{ shop.messenger|messenger_label }} {{ shop.messenger|messenger_display }}</a>{% else %}{{ shop.messenger|messenger_label }} {{ shop.messenger|messenger_display }}{% endif %}

Requirements

PHP 8.5 or later; phil/instant-messenger 0.1 and phil/enums 0.3; symfony/config, symfony/dependency-injection, symfony/form, symfony/options-resolver and symfony/validator 8.2 or later. Twig is optional.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.