Skip to main content

For developers

Custom checks

A custom check is a class implementing Pdir\AntiSpamBundle\AntiSpam\Check\SpamCheckInterface. In a bundle with autoconfiguration it is registered automatically (tag pdir_anti_spam.check) and contributes to the score.

Checks don’t return finished texts but a key under $GLOBALS['TL_LANG']['MSC']['pdir_anti_spam']['reason'][…] plus parameters. Translation happens on output.

Languages

All texts (back-end settings, notice text, honeypot label, log entries, error messages) are located in contao/languages/<language>/. German and English are included; for other languages Contao falls back to English. You can override individual texts as usual in your installation’s contao/languages/<language>/default.php.

New language: create the folder contao/languages/<language>/ with default.php and tl_settings.php. composer test checks keys and placeholders against the German texts.

Tests

composer install
composer test          # tests against the locally installed Contao version
composer test-matrix   # tests against Contao 4.13, 5.3, 5.7 and 6.0
composer cs-check      # checks the file header in all PHP files
composer phpstan       # static analysis (PHPStan level 8)

The tests include anonymised real spam samples as well as legitimate requests that must never be blocked. Add new spam patterns as a fixture in tests/Fixtures/Submissions.php first.