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

[FEATURE] Feature: #97201 - PSR-14 Event for modifying new content el… #1795

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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']
);
}
}

Original file line number Diff line number Diff line change
@@ -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