Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve conflict with powermail_cleaner #28

Open
sypets opened this issue Dec 10, 2024 · 1 comment
Open

Resolve conflict with powermail_cleaner #28

sypets opened this issue Dec 10, 2024 · 1 comment

Comments

@sypets
Copy link
Contributor

sypets commented Dec 10, 2024

There is currently a conflict with in2code/powermail_cleaner. The conflict is due to both extensions XCLASSing FormController.

This could be resolved if one of the extensions does not use XCLASS but uses for example the event In2code\Powermail\Events\FormControllerFormActionEvent

Unfortunately it is not possible to assign a variable to the view currently with this method.

I propose the following:

  • add PR to in2code/powermail to make it possible to get the view from the controller
  • add PR here to remove XCLASS and use the event

Example:

<?php

declare(strict_types=1);
namespace TRAW\Powermailcaptcha\EventListener;

use In2code\Powermail\Controller\AbstractController;
use In2code\Powermail\Domain\Model\Form;
use In2code\Powermail\Events\FormControllerFormActionEvent;
use In2code\Powermail\Utility\FrontendUtility;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 * >= v12 only
 *
 * Listens to event FormControllerFormActionEvent
 * @see \In2code\Powermail\Events\FormControllerFormActionEvent
 *
 * Documentation: How to listen to events
 * @see https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/EventDispatcher/Index.html
 */
final class PowermailFormControllerFormActionEventListener implements SingletonInterface
{
    public function __invoke(FormControllerFormActionEvent $event): void
    {
        $form = $event->getForm();
        if ($form === null) {
            return;
        }
        $formController = $event->getFormController();
        $settings = $formController->getSettings();

        if ($settings['powermailcaptcha']['useSiteLanguage'] ?? 0) {
             // !!!! this method does not exist
            $this->event->assignView('languageIso', $GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getLocale()->getLanguageCode());
        }
    }
}
sypets added a commit to sypets/powermailcaptcha that referenced this issue Dec 10, 2024
todo:

* [ ] Requires method to add a variable to the view in the EventListener

There was a conflict with powermail_cleaner because both extensions
XCLASSed FormController.

Resolvers: thomasrawiel#28
@thomasrawiel
Copy link
Owner

As there can be only one XCLASS per base class, this is actually a good suggestion. So thanks for that.

I'll wait if the PR in EXT:powermail gets accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants