<commit_before><?php

namespace ForkCMS\Modules\Extensions\Backend\Actions;

use ForkCMS\Core\Domain\Header\FlashMessage\FlashMessage;
use ForkCMS\Modules\Backend\Backend\Actions\UserGroupIndex;
use ForkCMS\Modules\Backend\Domain\Action\AbstractFormActionController;
use ForkCMS\Modules\Backend\Domain\UserGroup\Command\ChangeUserGroup;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\Command\ChangeThemeTemplate;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\ThemeTemplate;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\ThemeTemplateType;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

final class ThemeTemplateEdit extends AbstractFormActionController
{
    protected function getFormResponse(Request $request): ?Response
    {
        $themeTemplate = $this->getEntityFromRequest($request, ThemeTemplate::class);
        $this->assign('theme', $themeTemplate->getTheme());

        $this->setBreadcrumbDetail(
            sprintf(
                '%1$s: %2$s',
                $themeTemplate->getTheme()->getName(),
                $themeTemplate->getName()
            )
        );

        $this->addDeleteForm(['id' => $themeTemplate->getId()], ThemeTemplateDelete::getActionSlug());
        $changeThemeTemplate = new ChangeThemeTemplate($themeTemplate);

        return $this->handleForm(
            request: $request,
            formType: ThemeTemplateType::class,
            formData: $changeThemeTemplate,
            redirectResponse: new RedirectResponse(
                 ThemeTemplateIndex::getActionSlug()->generateRoute(
                     $this->router,<commit_msg>Don't allow deleteting default templates<commit_after><?php

namespace ForkCMS\Modules\Extensions\Backend\Actions;

use ForkCMS\Core\Domain\Header\FlashMessage\FlashMessage;
use ForkCMS\Modules\Backend\Domain\Action\AbstractFormActionController;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\Command\ChangeThemeTemplate;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\ThemeTemplate;
use ForkCMS\Modules\Extensions\Domain\ThemeTemplate\ThemeTemplateType;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

final class ThemeTemplateEdit extends AbstractFormActionController
{
    protected function getFormResponse(Request $request): ?Response
    {
        $themeTemplate = $this->getEntityFromRequest($request, ThemeTemplate::class);
        $this->assign('theme', $themeTemplate->getTheme());

        $this->setBreadcrumbDetail(
            sprintf(
                '%1$s: %2$s',
                $themeTemplate->getTheme()->getName(),
                $themeTemplate->getName()
            )
        );

        if (!$themeTemplate->isDefault()) {
            $this->addDeleteForm(['id' => $themeTemplate->getId()], ThemeTemplateDelete::getActionSlug());
        }

        $changeThemeTemplate = new ChangeThemeTemplate($themeTemplate);

        return $this->handleForm(
            request: $request,
            formType: ThemeTemplateType::class,
            formData: $changeThemeTemplate,
            redirectResponse: new RedirectResponse(
                 ThemeTemplateIndex::getActionSlug()->generateRoute(
                     $this->router,
{'fraction_non_alphanumeric': 0.10949330227140361, 'fraction_numerical': 0.0011648223645894002, 'mean_word_length': 3.6169354838709675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '530250', 'n_tokens_mistral': 894, 'n_tokens_neox': 887, 'n_words': 131}