Cleanup of tx_ter_helper
- Use Doctrine instead of legacy db connection
- Add types to variables and returns
- Simplify functions
- Remove unused code
- Use one SQL query to check availability of extension key (instead of getting all extensions and check in foreach)