mhinspeya/module-contact
Composer 安装命令:
composer require mhinspeya/module-contact
包简介
Custom contact form handler with field-level validation and custom redirect path.
README 文档
README
Custom Magento 2 contact form handler that replaces the core Magento_Contact POST controller with field-level validation and a custom redirect path.
Compatibility
| Magento | PHP |
|---|---|
| 2.4.4 – 2.4.8 | 8.2 · 8.3 · 8.4 |
Features
Custom Contact Form Handler
Replaces Magento\Contact\Controller\Index\Post via DI preference to provide:
- Field-level validation with specific error messages for each field (comment, email, honeypot)
- Custom redirect path — redirects to
kontakt/indexinstead of the defaultcontact/index - Structured exception handling — separates
LocalizedException(user-facing) from generic exceptions (logged as critical) - Full logging — all failures are logged via
Psr\Log\LoggerInterfacewith exception context
Validation Rules
| Field | Rule | Error Message |
|---|---|---|
comment | Must not be empty | "Please enter a comment." |
email | Must be a valid email | "Please enter a valid email address." |
hideit | Must be empty (honeypot) | Generic error (anti-spam) |
Email Configuration
Uses standard Magento contact email config paths:
| Config Path | Purpose |
|---|---|
contact/email/recipient_email | Recipient address |
contact/email/sender_email_identity | Sender identity |
contact/email/email_template | Email template ID |
Installation
Composer (recommended)
composer require mhinspeya/module-contact
bin/magento module:enable MHinspeya_Contact
bin/magento setup:upgrade
bin/magento cache:flush
Manual
- Copy the module files to
app/code/MHinspeya/Contact/ - Run:
bin/magento module:enable MHinspeya_Contact bin/magento setup:upgrade bin/magento cache:flush
Module Structure
MHinspeya/Contact/
├── composer.json
├── registration.php
├── etc/
│ ├── module.xml — Module declaration (depends on Magento_Contact)
│ └── di.xml — Preference: replaces core Post controller
├── i18n/
│ └── de_DE.csv — German translations
└── Controller/
└── Index/
└── Post.php — Custom contact form POST handler
Architecture
- Implements:
Magento\Framework\App\Action\HttpPostActionInterface(modern Magento controller pattern) - Replaces:
Magento\Contact\Controller\Index\Postvia<preference>indi.xml - Dependencies: All injected via constructor DI — no ObjectManager usage
Translations
| Key | de_DE |
|---|---|
| Thanks for contacting us... | Vielen Dank für Ihre Nachricht... |
| We can't process your request... | Wir können Ihre Anfrage derzeit nicht bearbeiten... |
| Please enter a comment. | Bitte geben Sie einen Kommentar ein. |
| Please enter a valid email address. | Bitte geben Sie eine gültige E-Mail-Adresse ein. |
License
Proprietary — © MHinspeya
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2026-06-26