diff --git a/Documentation/ApiOverview/Hooks/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst b/Documentation/ApiOverview/Hooks/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst new file mode 100644 index 0000000000..72d74358fe --- /dev/null +++ b/Documentation/ApiOverview/Hooks/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst @@ -0,0 +1,64 @@ +.. include:: /Includes.rst.txt +.. index:: Events; ModifyNewContentElementWizardItemsEvent +.. _ModifyNewContentElementWizardItemsEvent: + +============================================= +ModifyNewContentElementWizardItemsEvent +============================================= + +.. versionadded:: 12.0 + This event serves as a more powerful and flexible alternative + for the removed hook :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook']`. + +The event is called after TYPO3 has already prepared the wizard items, +defined in TSconfig (:typoscript:`mod.wizards.newContentElement.wizardItems`). + +The event allows listeners to modify any available wizard item as well +as adding new ones. It's therefore possible for the listeners to e.g. change +the configuration, the position or to remove existing items altogether. + +API +=== + +.. include:: /CodeSnippets/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst.txt + +Example +======= + +Registration of the Event in your extensions' :file:`Services.yaml`: + +.. code-block:: yaml + :caption: EXT:my_extension/Configuration/Services.yaml + + MyVendor\MyPackage\Backend\MyEventListener: + tags: + - name: event.listener + identifier: 'my-package/backend/modify-wizard-items' + +The corresponding event listener class: + +.. code-block:: php + :caption: EXT:my_extension/Classes/Backend/MyEventListener.php + + use TYPO3\CMS\Backend\Controller\Event\ModifyNewContentElementWizardItemsEvent; + + class MyEventListener { + + public function __invoke(ModifyNewContentElementWizardItemsEvent $event): void + { + // Add a new wizard item after "textpic" + $event->setWizardItem( + 'my_element', + [ + 'iconIdentifier' => 'icon-my-element', + 'title' => 'My element', + 'description' => 'My element description', + 'tt_content_defValues' => [ + 'CType' => 'my_element' + ], + ], + ['after' => 'common_textpic'] + ); + } + } + diff --git a/Documentation/CodeSnippets/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst.txt b/Documentation/CodeSnippets/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst.txt new file mode 100644 index 0000000000..7b8bddfead --- /dev/null +++ b/Documentation/CodeSnippets/Events/Backend/ModifyNewContentElementWizardItemsEvent.rst.txt @@ -0,0 +1,65 @@ +.. Generated by https://github.com/linawolf/t3docs_restructured_api_tools + +.. php:namespace:: TYPO3\CMS\Backend\Controller\Event + +.. php:class:: ModifyNewContentElementWizardItemsEvent + + Listeners to this Event will be able to modify the wizard items of the new content element wizard component + + + .. php:method:: getWizardItems() + + :returntype: array + + .. php:method:: setWizardItems(array wizardItems) + + :param array $wizardItems: the wizardItems + + .. php:method:: hasWizardItem(string identifier) + + :param string $identifier: the identifier + :returntype: bool + + .. php:method:: getWizardItem(string identifier) + + :param string $identifier: the identifier + :returntype: array + + .. php:method:: setWizardItem(string identifier, array configuration, array position = array ()) + + Add a new wizard item with configuration at a defined position. + + Can also be used to relocate existing items and to modify their configuration. + + :param string $identifier: the identifier + :param array $configuration: the configuration + :param array $position: the position, default: array () + + .. php:method:: removeWizardItem(string identifier) + + :param string $identifier: the identifier + :returntype: bool + + .. php:method:: getPageInfo() + + Provides information about the current page making use of the wizard. + + :returntype: array + + .. php:method:: getColPos() + + Provides information about the column position of the button that triggered the wizard. + + :returntype: int + + .. php:method:: getSysLanguage() + + Provides information about the language used while triggering the wizard. + + :returntype: int + + .. php:method:: getUidPid() + + Provides information about the element to position the new element after (uid) or into (pid). + + :returntype: int