diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php deleted file mode 100644 index 27ab961..0000000 --- a/Classes/Controller/AbstractController.php +++ /dev/null @@ -1,61 +0,0 @@ -eventDispatcher->dispatch( - new PostProcessFluidVariablesEvent( - $this->request, - $this->settings, - $variables, - ), - ); - - $this->view->assignMultiple($event->getFluidVariables()); - } - - protected function postProcessControllerAction(?Company $company): void - { - $this->eventDispatcher->dispatch( - new PostProcessControllerActionEvent( - $this, - $company, - $this->settings, - $this->request, - ), - ); - } - - protected function preProcessControllerAction(): void - { - $this->eventDispatcher->dispatch( - new PreProcessControllerActionEvent( - $this->request, - $this->arguments, - $this->settings, - ), - ); - } -} diff --git a/Classes/Controller/CompanyController.php b/Classes/Controller/CompanyController.php index 97b99f3..2a5341b 100644 --- a/Classes/Controller/CompanyController.php +++ b/Classes/Controller/CompanyController.php @@ -18,6 +18,9 @@ use JWeiland\Yellowpages2\Domain\Repository\DistrictRepository; use JWeiland\Yellowpages2\Domain\Repository\FeUserRepository; use JWeiland\Yellowpages2\Helper\MailHelper; +use JWeiland\Yellowpages2\Traits\PostProcessControllerActionTrait; +use JWeiland\Yellowpages2\Traits\PostProcessFluidVariablesTrait; +use JWeiland\Yellowpages2\Traits\PreProcessControllerActionTrait; use JWeiland\Yellowpages2\Utility\CacheUtility; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Context\Context; @@ -27,13 +30,18 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; use TYPO3\CMS\Extbase\Annotation\Validate; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** * Controller to list, show and search for companies */ -class CompanyController extends AbstractController +class CompanyController extends ActionController { + use PostProcessFluidVariablesTrait; + use PostProcessControllerActionTrait; + use PreProcessControllerActionTrait; + public function __construct( private readonly Context $context, private readonly CompanyRepository $companyRepository, diff --git a/Classes/Controller/MapController.php b/Classes/Controller/MapController.php index c640df6..a5cd2d1 100644 --- a/Classes/Controller/MapController.php +++ b/Classes/Controller/MapController.php @@ -17,16 +17,24 @@ use JWeiland\Yellowpages2\Domain\Model\Company; use JWeiland\Yellowpages2\Domain\Repository\CompanyRepository; use JWeiland\Yellowpages2\Helper\MailHelper; +use JWeiland\Yellowpages2\Traits\PostProcessControllerActionTrait; +use JWeiland\Yellowpages2\Traits\PostProcessFluidVariablesTrait; +use JWeiland\Yellowpages2\Traits\PreProcessControllerActionTrait; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** * Controller to show and save PoiCollections on a map */ -class MapController extends AbstractController +class MapController extends ActionController { + use PostProcessFluidVariablesTrait; + use PostProcessControllerActionTrait; + use PreProcessControllerActionTrait; + protected CompanyRepository $companyRepository; protected PersistenceManagerInterface $persistenceManager; diff --git a/Classes/Traits/PostProcessControllerActionTrait.php b/Classes/Traits/PostProcessControllerActionTrait.php new file mode 100644 index 0000000..8b41214 --- /dev/null +++ b/Classes/Traits/PostProcessControllerActionTrait.php @@ -0,0 +1,30 @@ +eventDispatcher->dispatch( + new PostProcessControllerActionEvent( + $this, + $company, + $this->settings, + $this->request, + ), + ); + } +} diff --git a/Classes/Traits/PostProcessFluidVariablesTrait.php b/Classes/Traits/PostProcessFluidVariablesTrait.php new file mode 100644 index 0000000..73051c5 --- /dev/null +++ b/Classes/Traits/PostProcessFluidVariablesTrait.php @@ -0,0 +1,30 @@ +eventDispatcher->dispatch( + new PostProcessFluidVariablesEvent( + $this->request, + $this->settings, + $variables, + ), + ); + + $this->view->assignMultiple($event->getFluidVariables()); + } +} diff --git a/Classes/Traits/PreProcessControllerActionTrait.php b/Classes/Traits/PreProcessControllerActionTrait.php new file mode 100644 index 0000000..1601eb0 --- /dev/null +++ b/Classes/Traits/PreProcessControllerActionTrait.php @@ -0,0 +1,28 @@ +eventDispatcher->dispatch( + new PreProcessControllerActionEvent( + $this->request, + $this->arguments, + $this->settings, + ), + ); + } +}