<?php
defined('TYPO3_MODE') || die();


/* ===========================================================================
  Hooks
=========================================================================== */
// Add wizard with map for setting geo location
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1650971524] = [
   'nodeName' => 'latLonMapWizard',
   'priority' => 30,
   'class' => \A2G\A2gMaps\FormEngine\FieldControl\LocationMapWizard::class
];


// PageTS
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:a2g_maps/Configuration/TsConfig/Page/All.tsconfig">');

call_user_func(static function() {
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'A2gMaps',
        'map',
        [
            \A2G\A2gMaps\Controller\MapController::class => 'map, popup, mapMarkers'
        ],
        // non-cacheable actions
        [
            \A2G\A2gMaps\Controller\MapController::class => ''
        ]
    );


    // wizards
    /*
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
        'mod {
            wizards.newContentElement.wizardItems.plugins {
                elements {
                    map {
                        iconIdentifier = a2g_maps-plugin-map
                        title = LLL:EXT:a2g_maps/Resources/Private/Language/locallang_db.xlf:a2g_maps.name
                        description = LLL:EXT:a2g_maps/Resources/Private/Language/locallang_db.xlf:a2g_maps.description
                        tt_content_defValues {
                            CType = list
                            list_type = a2g_maps
                        }
                    }
                }
                show = *
            }
       }'
    );
    */
    
    $pluginIcons = [
        'a2g_maps-plugin-map' => 'EXT:a2g_maps/Resources/Public/Icons/map.png'
    ];
    $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);

    foreach($pluginIcons as $key => $icon){
        $iconRegistry->registerIcon(
            $key,
            \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
            ['source' => $icon]
        );
    }
});


$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['a2g_maps']
  = \A2G\A2gMaps\Hooks\MapEntryDataHandlerHooks::class;

/***************
 * Register "a2g" as global fluid namespace
 */
//$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['a2gmaps'][] = 'A2G\\A2gMaps\\ViewHelpers';