<?php

/**
 * Allow language synchronization for FAL fields
 */

$allowSync = [
    'tt_content' => [
        'image',
        'media'
    ]
];

foreach ($allowSync as $syncTablename => $syncColumns) {
    foreach ($syncColumns as $syncColumn) {
        $GLOBALS['TCA'][$syncTablename]['columns'][$syncColumn]['config']['behaviour']['allowLanguageSynchronization'] = 1;
    }
}

/**
 * Add crop editor
 */

$cropConfiguration = \CYBOB\BaggerSitePackage\Utility\TcaUtility::getDefaultCropConfiguration();

$cropColumnsByType = [
    'image' => [
        'image'
    ],
    'menu_pages' => [
        'image'
    ],
    'menu_subpages' => [
        'image'
    ],
    'menu_categorized_pages' => [
        'image'
    ]
];

foreach ($cropColumnsByType as $type => $cropColumns) {
    foreach ($cropColumns as $cropColumn) {
        $GLOBALS['TCA']['tt_content']['types'][$type]['columnsOverrides'][$cropColumn]['config']['overrideChildTca']['columns']['crop']['config'] = [
            'cropVariants' => array_merge_recursive(
                [
                    'default' => [
                        'disabled' => true
                    ]
                ],
                $cropConfiguration
            )
        ];
    }
}
