Markus Michalski FAQ

Accessibility Widget: Technical Details

Accessibility widget for Sylius - flow diagram, plugin structure, entity and migration overview

Deutsche Version

Back to overview

Accessibility Widget: Technical Details

Live Demo: Try this and other plugins live β€” no installation, no risk: demo.markus-michalski.net

Flow

graph TD
    A["Storefront request"] --> B["WidgetConfigResolverInterface"]
    H["Shop API request"] --> B
    B --> C["ChannelSettingsRepositoryInterface"]
    C --> D[("mmd_sylius_accessibility_channel_settings")]
    D --> E{"Row enabled?"}
    E -->|"No"| F["No widget / HTTP 404"]
    E -->|"Yes"| G["WidgetConfig"]
    G --> I["Twig hooks: stylesheets, javascripts, header, offcanvas"]
    G --> J["AccessibilitySettingsProvider (Shop API)"]

The result is cached once per request and channel code (WidgetConfigResolver, kernel.reset), because several storefront templates on the same page ask for the same channel. A database error is not cached.

Bundle and resources

Element Value
Composer package mmd/sylius-accessibility-plugin
Bundle class Mmd\SyliusAccessibilityPlugin\MmdSyliusAccessibilityPlugin
Configuration tree mmd_sylius_accessibility, deliberately empty
Sylius resource mmd_sylius_accessibility_plugin.accessibility_settings (Doctrine ORM)
Admin route (index) mmd_sylius_accessibility_plugin_admin_accessibility_settings_index under /%sylius_admin.path_name%/accessibility-channel-settings (all CRUD routes except show)
Shop API operation GET /shop/accessibility-settings (under the API prefix /api/v2)
Console command mmd:accessibility:setup
Sidebar group MMKreativ Plugins (code mmd_plugins, shared with other MMKreativ plugins)

Plugin structure

src/
β”œβ”€β”€ Api/
β”‚   β”œβ”€β”€ AccessibilitySettingsProvider.php     # API Platform state provider
β”‚   └── Resource/AccessibilitySettings.php    # API resource (GET /shop/accessibility-settings)
β”œβ”€β”€ DependencyInjection/
β”‚   β”œβ”€β”€ Configuration.php
β”‚   └── MmdSyliusAccessibilityExtension.php   # bundle extension, Doctrine/grid/hook prepend
β”œβ”€β”€ Command/SetupCommand.php                  # mmd:accessibility:setup
β”œβ”€β”€ Entity/
β”‚   β”œβ”€β”€ ChannelSettings.php                   # the only own table
β”‚   β”œβ”€β”€ ChannelSettingsInterface.php
β”‚   └── WidgetPosition.php                    # enum: bottom_right, bottom_left
β”œβ”€β”€ Form/Type/ChannelSettingsFormType.php     # @internal
β”œβ”€β”€ Menu/
β”‚   β”œβ”€β”€ AdminMenuListener.php                 # @internal
β”‚   └── MenuGroup.php                         # "MMKreativ Plugins" sidebar group
β”œβ”€β”€ Migrations/Version20261003140000.php
β”œβ”€β”€ Settings/
β”‚   β”œβ”€β”€ ChannelSettingsRepository.php
β”‚   └── ChannelSettingsRepositoryInterface.php
β”œβ”€β”€ Twig/AccessibilityTwigExtension.php       # @internal
└── Widget/
    β”œβ”€β”€ WidgetConfig.php
    β”œβ”€β”€ WidgetConfigResolver.php
    └── WidgetConfigResolverInterface.php
config/                                       # services, admin routes, grid, Twig hooks
templates/                                    # shop/ (skip link, target, widget, stylesheets, javascripts), admin/
translations/                                 # messages, flashes, validators (de, en)
Resources/public/                             # accessibility.css, accessibility-early.js, accessibility.js

Entity

A single table, mmd_sylius_accessibility_channel_settings, keyed by channel_code instead of a foreign key - the plugin needs no Sylius core table in its own mapping for that.

Column Type Meaning
id integer, auto increment Primary key
channel_code string(255), unique Channel code, no foreign key
enabled boolean Widget on/off (default off)
position string(16) bottom_right / bottom_left
skip_link_enabled boolean Skip link on/off
show_font_size boolean Font size tool
show_contrast boolean Contrast tool
show_color_filter boolean Colour filter tool
show_blue_light boolean Blue light filter tool
show_animations boolean Reduce animations tool

Frontend

Plain JavaScript and CSS without a build step. accessibility-early.js holds the schema, storage and application of the settings and exposes them as window.MmdAccessibility; accessibility.js builds the panel behaviour on top of it. The widget sends no network requests.