diff --git a/Classes/Controller/NewsController.php b/Classes/Controller/NewsController.php index 3562bdabc6..208781a4cb 100644 --- a/Classes/Controller/NewsController.php +++ b/Classes/Controller/NewsController.php @@ -15,6 +15,7 @@ use GeorgRinger\News\Domain\Repository\CategoryRepository; use GeorgRinger\News\Domain\Repository\NewsRepository; use GeorgRinger\News\Domain\Repository\TagRepository; +use GeorgRinger\News\Event\CreateDemandObjectFromSettingsEvent; use GeorgRinger\News\Event\NewsCheckPidOfNewsRecordFailedInDetailActionEvent; use GeorgRinger\News\Event\NewsDateMenuActionEvent; use GeorgRinger\News\Event\NewsDetailActionEvent; @@ -167,6 +168,11 @@ protected function createDemandObjectFromSettings( GeneralUtility::callUserFunction($reference, $params, $this); } } + + $event = new CreateDemandObjectFromSettingsEvent($demand, $settings, $class); + $this->eventDispatcher->dispatch($event); + $demand = $event->getDemand(); + return $demand; } diff --git a/Classes/Event/CreateDemandObjectFromSettingsEvent.php b/Classes/Event/CreateDemandObjectFromSettingsEvent.php new file mode 100644 index 0000000000..dd36f3eaf7 --- /dev/null +++ b/Classes/Event/CreateDemandObjectFromSettingsEvent.php @@ -0,0 +1,47 @@ +demand = $demand; + $this->settings = $settings; + $this->class = $class; + } + + public function getDemand(): NewsDemand + { + return $this->demand; + } + + public function getSettings(): array + { + return $this->settings; + } + + public function getClass(): string + { + return $this->class; + } + + public function setDemand(NewsDemand $demand): void + { + $this->demand = $demand; + } + +} diff --git a/Documentation/Tutorials/ExtendNews/Demands/Index.rst b/Documentation/Tutorials/ExtendNews/Demands/Index.rst index 32aeb643b7..4bc2b1f105 100644 --- a/Documentation/Tutorials/ExtendNews/Demands/Index.rst +++ b/Documentation/Tutorials/ExtendNews/Demands/Index.rst @@ -56,33 +56,6 @@ extending EXT:news. Read more about using a demand object in a custom controller: :ref:`Extension based on EXT:news: FilterController.php `. -Hooks -===== - -Several hooks can be used to influence the demand object and its usage. - -Hook findDemanded ------------------ - -The hook :code:`findDemanded` is very -powerful. It allows to modify the query used to fetch the news records depending -on values set in the demand object. You can find an example of how to use it in -the chapter :ref:`Hooks: Example findDemanded `. - -Hook createDemandObjectFromSettings ------------------------------------ - -The hook :code:`createDemandObjectFromSettings` -(:php:`$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['Controller/NewsController.php']['createDemandObjectFromSettings']`) -can be used to influence the settings of the demand object as it is used in -most standard actions in the :php:`NewsController`, such as the -:php:`listAction()`, :php:`selectedListAction()` and :php:`detailAction()`. - -This hook can be used to insert settings from custom TypoScript or custom -FlexForm configuration into the demand object. (See also -:ref:`Extend FlexForms `) - - Events ====== diff --git a/Documentation/Tutorials/ExtendNews/Hooks/Index.rst b/Documentation/Tutorials/ExtendNews/Hooks/Index.rst index 6b2121278c..8fbf84b258 100644 --- a/Documentation/Tutorials/ExtendNews/Hooks/Index.rst +++ b/Documentation/Tutorials/ExtendNews/Hooks/Index.rst @@ -1,8 +1,8 @@ -.. _hooks: +.. _events: -===== -Hooks -===== +====== +Events +====== Several events can be used to modify the behaviour of EXT:news. @@ -10,7 +10,7 @@ Several events can be used to modify the behaviour of EXT:news. :local: :depth: 1 -Hooks +Events ----- .. event_example_findDemanded: @@ -58,7 +58,7 @@ Now create the file ``Classes/EventListener/ModifyDemandRepositoryEventListener. Controller/NewsController overrideSettings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Use this hook to change the final settings which are for building queries, for the template, ... +Use this evebt to change the final settings which are for building queries, for the template, ... Example """""""