# Add Data Processors ## Introduction Let's say you want to easily add some own php functions, that should be called before the mail object will be persisted and send to the receivers or if you want to override original DataProcessors from powermail, a DataProcessor will be the best choice. Maybe you want to: * Change user inputs * Do a redirect before mails will be sent * Add additional information before the mail object will be stored * Something else... ## Small example Just define which classes should be used. Every method like `*DataProcessor()` will be called - e.g. `myNewDataProcessor()`: ``` plugin.tx_powermail.settings.setup { dataProcessors { 1 { class = Vendor\Ext\DataProcessor\DoSomethingDataProcessor } } } ``` Add a php-file and extend your class with the AbstractDataProcessor from powermail: ``` configuration['foo']; // get subject from mail $subject = $this->getMail()->getSubject(); // get a value by markername $value = $mail->getAnswersByFieldMarker()['markerName']->getValue(); // get a value by field uid $value = $mail->getAnswersByFieldUid()[123]->getValue(); // do some more magic ... } } ``` ## Some notices * All methods which are ending with "DataProcessor" will be called - e.g. uploadDataProcessor() * The method initializeDataProcessor() will always be called at first * Every dataProcessor method could have its own initialize method, which will be called before. Like initializeMyDataProcessor() before myDataProcessor() * Classes in extensions (if namespace and filename fits) will be automaticly included from TYPO3 autoloader. If you place a single file in fileadmin, use "require" in TypoScript * Per default 10 and 20 is already in use from powermail itself (SessionDataProcessor, UploadDataProcessor).