phil / content-warnings-bundle
phil/content-warnings in Symfony: the catalogue of warning themes from configuration, the JSON column type phil_content_warnings, fields for warnings and preferences, a folded display in Twig with a Stimulus controller, and a store of each member's preferences
Package info
github.com/parler-haut-interagir-librement/content-warnings-bundle
Type:symfony-bundle
pkg:composer/phil/content-warnings-bundle
Requires
- php: >=8.5
- ext-intl: *
- phil/content-warnings: ^0.1@dev
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/form: ^8.2
- symfony/options-resolver: ^8.2
- symfony/service-contracts: ^3.6
Requires (Dev)
- doctrine/dbal: ^4.5
- doctrine/doctrine-bundle: ^3.3
- doctrine/orm: ^3.7
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- symfony/event-dispatcher: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-foundation: ^8.2
- symfony/http-kernel: ^8.2
- symfony/translation: ^8.2
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- twig/twig: ^3.21
Suggests
- doctrine/dbal: For the phil_content_warnings column type
- symfony/http-foundation: For SessionWarningPreferences, the default store of preferences
- twig/twig: For the Twig functions and the folded display
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 13:32:00 UTC
README
Content warnings in Symfony applications: a catalogue from configuration, warnings on any entity, and content folded or hidden as each reader chooses.
phil/content-warnings-bundle brings phil/content-warnings into Symfony. The catalogue of warning themes is built
from the library's base list, in six languages, completed or replaced by the application's configuration and
definition files; a definition that breaks a rule stops the container build. The column type phil_content_warnings
keeps the warnings of any entity — a game, a book, an article, an event — in one JSON column. ContentWarningsType
picks them among the themes, grouped by category, and WarningPreferencesType lets a reader choose a display per
category and per theme. The template @PhilContentWarnings/fold.html.twig shows a piece of content with its warnings,
folds it behind them in an accessible details element that the Stimulus controller reveal drives, or leaves it out.
Labels and messages are in English, French, Spanish, German, Italian and Portuguese.
It is for Symfony applications that publish content some readers would rather approach with care, and that let those
readers choose. Preferences are read through the port WarningPreferencesStore: the bundle keeps them in the session
by default, and an application with member settings implements the port over them.
Outside Symfony, or for the catalogue, warnings and decisions alone, use phil/content-warnings. The bundle is a thin
layer over it: configuration, a column type, form fields, Twig functions, a template and a store.
Status
| Part | State |
|---|---|
| The catalogue from configuration and definition files | Implemented and tested |
The column type phil_content_warnings |
Implemented and tested |
ContentWarningsType, its form theme, and WarningPreferencesType |
Implemented and tested |
Twig functions and @PhilContentWarnings/fold.html.twig |
Implemented and tested |
The Stimulus controller reveal and its stylesheet |
Implemented and tested |
WarningPreferencesStore, with the session and in-memory stores |
Implemented and tested |
| Labels and messages in six languages | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements and registering. |
| Configuration | The base list, definition files, the default display, locales and the store. |
| Doctrine | The column type phil_content_warnings. |
| Forms | ContentWarningsType, its theme, and WarningPreferencesType. |
| Display | The template, the Twig functions, the Stimulus controller, the stylesheet and accessibility. |
| Preferences | The port WarningPreferencesStore and the stores shipped. |
| Extension points | What an application configures, implements, replaces or relies on. |
| Testing | How the bundle is tested. |
| Reference | Every type of the bundle. |
Quick start
composer require phil/content-warnings-bundle
#[ORM\Column(type: 'phil_content_warnings', nullable: true)] private ?ContentWarnings $warnings = null; $builder->add('warnings', ContentWarningsType::class);
{% embed '@PhilContentWarnings/fold.html.twig' with {warnings: book.warnings} %}
{% block content %}{{ book.excerpt }}{% endblock %}
{% endembed %}
Requirements
PHP 8.5 or later with ext-intl; phil/content-warnings 0.1; symfony/config, symfony/dependency-injection,
symfony/form and symfony/options-resolver 8.2 or later, symfony/service-contracts 3.6 or later. Doctrine DBAL,
HttpFoundation and Twig are 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.