src/Dca/DcaUtil.php
public function addAliasToDca(string $dca, $generateAliasCallback, string $paletteField, array $palettes = ['default'])
    {
        Controller::loadDataContainer($dca);

        $arrDca = &$GLOBALS['TL_DCA'][$dca];

        // add to palettes
        foreach ($palettes as $strPalette) {
            $arrDca['palettes'][$strPalette] = str_replace($paletteField.',', $paletteField.',alias,', $arrDca['palettes'][$strPalette]);
        }

        // add field
        $arrDca['fields']['alias'] = [
            'label' => &$GLOBALS['TL_LANG']['MSC']['alias'],
            'exclude' => true,
            'search' => true,
            'inputType' => 'text',
            'eval' => ['rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'],
            'save_callback' => [$generateAliasCallback],
            'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''",
        ];
    }
public function addAliasToDca(string $dca, $generateAliasCallback, string $paletteField, array $palettes = ['default'])
    {
        Controller::loadDataContainer($dca);

        $arrDca = &$GLOBALS['TL_DCA'][$dca];

        // add to palettes
        foreach ($palettes as $strPalette) {
            $arrDca['palettes'][$strPalette] = str_replace($paletteField.',', $paletteField.',alias,', $arrDca['palettes'][$strPalette]);
        }

        // add field
        $arrDca['fields']['alias'] = [
            'label' => &$GLOBALS['TL_LANG']['MSC']['alias'],
            'exclude' => true,
            'search' => true,
            'inputType' => 'text',
            'eval' => ['rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'],
            'save_callback' => [$generateAliasCallback],
            'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''",
        ];
    }
public function addAliasToDca ( string $ dca , $ generateAliasCallback , string $ paletteField , array $ palettes = [ 'default' ] ) { Controller :: loadDataContainer ( $ dca ) ; $ arrDca = & $ GLOBALS [ 'TL_DCA' ] [ $ dca ] ; // add to palettes foreach ( $ palettes as $ strPalette ) { $ arrDca [ 'palettes' ] [ $ strPalette ] = str_replace ( $ paletteField . ',' , $ paletteField . ',alias,' , $ arrDca [ 'palettes' ] [ $ strPalette ] ) ; } // add field $ arrDca [ 'fields' ] [ 'alias' ] = [ 'label' => & $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'alias' ] , 'exclude' => true , 'search' => true , 'inputType' => 'text' , 'eval' => [ 'rgxp' => 'alias' , 'unique' => true , 'maxlength' => 128 , 'tl_class' => 'w50' ] , 'save_callback' => [ $ generateAliasCallback ] , 'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''" , ] ; }
Adds an alias field to the dca and to the desired palettes.

@param       $dca
@param       $generateAliasCallback mixed The callback to call for generating the alias
@param       $paletteField          String The field after which to insert the alias field in the palettes
@param array $palettes              The palettes in which to insert the field
Adds an alias field to the dca and to the desired palettes .