<commit_before><?php
foreach ($actions as $config) {
    $config += ['method' => 'GET'];

    if ((empty($config['url']['controller']) ||
            $this->request->controller === $config['url']['controller']) &&
        $this->request->action === $config['url']['action']
    ) {
        continue;
    }

    $linkOptions = ['class' => 'btn btn-default'];
    if (isset($config['options'])) {
        $linkOptions = $config['options'] + $linkOptions;
    }

    if ($config['method'] === 'DELETE') {
        $linkOptions += [
            'confirm' => __d('crud', 'Are you sure you want to delete record #{0}?', [$singularVar->{$primaryKey}])
        ];
    }

    if ($config['method'] !== 'GET') {
        $linkOptions += [
            'method' => $config['method']
        ];
    }

    $url = $config['url'];
    if (!empty($singularVar)) {
        if (!empty($config['map'])) {
            foreach ($config['map'] as $key => $prop) {
                $url[$key] = $singularVar[$prop];
            }
        } else {
            $url[] = $singularVar->{$primaryKey};
        }
    }

    if ($config['method'] !== 'GET') {
        echo $this->Form->postLink(
            $config['title'],
            $url,
            $linkOptions
        );
        continue;
    }

    echo $this->Html->link(
        $config['title'],
        $url,
        $linkOptions
    );
}
<commit_msg>Allow using callback for action link generation.<commit_after><?php
foreach ($actions as $config) {
    $config += ['method' => 'GET'];

    if ((empty($config['url']['controller']) || $this->request->controller === $config['url']['controller']) &&
        (!empty($config['url']['action']) && $this->request->action === $config['url']['action'])
    ) {
        continue;
    }

    $linkOptions = ['class' => 'btn btn-default'];
    if (isset($config['options'])) {
        $linkOptions = $config['options'] + $linkOptions;
    }

    if ($config['method'] === 'DELETE') {
        $linkOptions += [
            'confirm' => __d('crud', 'Are you sure you want to delete record #{0}?', [$singularVar->{$primaryKey}])
        ];
    }

    if ($config['method'] !== 'GET') {
        $linkOptions += [
            'method' => $config['method']
        ];
    }

    if (!empty($config['callback'])) {
        $callback = $config['callback'];
        unset($config['callback']);
        $config['linkOptions'] = $linkOptions;
        echo $callback($config, !empty($singularVar) ? $singularVar : null);
    }

    $url = $config['url'];
    if (!empty($singularVar)) {
        if (!empty($config['map'])) {
            foreach ($config['map'] as $key => $prop) {
                $url[$key] = $singularVar[$prop];
            }
        } else {
            $url[] = $singularVar->{$primaryKey};
        }
    }

    if ($config['method'] !== 'GET') {
        echo $this->Form->postLink(
            $config['title'],
            $url,
            $linkOptions
        );
        continue;
    }

    echo $this->Html->link(
        $config['title'],
        $url,
        $linkOptions
    );
}

{'fraction_non_alphanumeric': 0.21549479166666666, 'fraction_numerical': 0.0006510416666666666, 'mean_word_length': 2.1071789686552074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '224785', 'n_tokens_mistral': 918, 'n_tokens_neox': 889, 'n_words': 171}