<?php
defined('TYPO3') || die('Access denied.');

call_user_func(
    function()
    {

        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
            'Persons',
            'Person',
            [
                \Medienreaktor\Persons\Controller\PersonController::class => 'list, show'
            ],
            // non-cacheable actions
            [
                \Medienreaktor\Persons\Controller\PersonController::class => ''
            ]
        );

        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
            'Persons',
            'Teasermap',
            [
                \Medienreaktor\Persons\Controller\AddressController::class => 'teasers',
            ],
            // non-cacheable actions
            [
                \Medienreaktor\Persons\Controller\AddressController::class => ''
            ]
        );

        \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
            'Persons',
            'Map',
            [
                \Medienreaktor\Persons\Controller\LocationController::class => 'list',
            ],
            // non-cacheable actions
            [
                \Medienreaktor\Persons\Controller\LocationController::class => ''
            ]
        );

    // wizards
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
        'mod {
            wizards.newContentElement.wizardItems.plugins {
                elements {
                    person {
                        iconIdentifier = persons-plugin-person
                        title = Person
                        description = Fügt den Kontakt einer Person ein
                        tt_content_defValues {
                            CType = list
                            list_type = persons_person
                        }
                    }
                    teasermap {
                        iconIdentifier = persons-plugin-teasermap
                        title = Teaser Karte
                        description = Fügt den Kontakt einer Person ein
                        tt_content_defValues {
                            CType = list
                            list_type = persons_teasermap
                        }
                    }
                    map {
                        iconIdentifier = persons-plugin-map
                        title = Karte
                        description = Fügt eine Karte ein
                        tt_content_defValues {
                            CType = list
                            list_type = persons_map
                        }
                    }
                }
                show = *
            }
       }'
    );
		$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);

			$iconRegistry->registerIcon(
				'persons-plugin-person',
				\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
				['source' => 'EXT:persons/Resources/Public/Icons/user_plugin_persons.svg']
			);
            $iconRegistry->registerIcon(
                'persons-plugin-teasermap',
                \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
                ['source' => 'EXT:persons/Resources/Public/Icons/user_plugin_persons.svg']
            );
            $iconRegistry->registerIcon(
                'persons-plugin-map',
                \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
                ['source' => 'EXT:persons/Resources/Public/Icons/user_plugin_persons.svg']
            );

    }
);

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask::class] = array(
    'extension' => 'persons',
    'title' => 'Place Geo Controller',
    'description' => ''
);