<commit_before><?php
namespace thinkbuilder\generator\php;

use thinkbuilder\generator\Generator;
use thinkbuilder\helper\TemplateHelper;

/**
 * Class MenuData 菜单数据生成器
 * @package thinkbuilder\generator\php
 */
class MenuData extends Generator
{
    public function generate(): Generator
    {
        $data = $this->params['data'];
        $items = "\t['title' => '{$data['caption']}', 'url' => '', 'sub_menu' =>" . PHP_EOL;
        $items .= " \t\t[" . PHP_EOL;
        foreach ($data['modules'] as $module) {
            $items .= "\t\t['title' => '{$module['caption']}', 'url' => '', 'sub_menu' =>" . PHP_EOL;
            $items .= " \t\t\t[" . PHP_EOL;
            //处理 model，并创建自动控制器
            $controllers = [];
            foreach ($module['models'] as $model) {
                $controllers[] = ['name' => $model['name'], 'caption' => $model['caption']];
            }
            $controllers = array_merge($module['controllers'], $controllers);

            //根据 controller 来生成菜单索引
            foreach ($controllers as $controller) {
                $items .= "\t\t\t\t['title' => '{$controller['caption']}', 'url' => '{$module['name']}/{$controller['name']}/index']," . PHP_EOL;
            }
            $items .= "\t\t\t\t]" . PHP_EOL;
            $items .= "\t\t\t]," . PHP_EOL;
        }
        $items .= "\t\t]" . PHP_EOL;
        $items .= "\t]";
        $this->content = TemplateHelper::parseTemplateTags(['ITEMS' => $items], $this->params['template']);
        return $this;
    }
}<commit_msg>修改：生成三级菜单<commit_after><?php
namespace thinkbuilder\generator\php;

use thinkbuilder\generator\Generator;
use thinkbuilder\helper\TemplateHelper;

/**
 * Class MenuData 菜单数据生成器
 * @package thinkbuilder\generator\php
 */
class MenuData extends Generator
{
    public function generate(): Generator
    {
        $data = $this->params['data'];
        $items = "\t['title' => '{$data['caption']}', 'url' => '', 'icon' => 'fa-folder', 'sub_menu' =>" . PHP_EOL;
        $items .= " \t\t[" . PHP_EOL;
        foreach ($data['modules'] as $module) {
            $items .= "\t\t['title' => '{$module['caption']}', 'url' => '', 'icon' => 'fa-folder', 'sub_menu' =>" . PHP_EOL;
            $items .= " \t\t\t[" . PHP_EOL;
            //处理 model，并创建自动控制器
            $controllers = [];
            foreach ($module['models'] as $model) {
                $controllers[] = ['name' => $model['name'], 'caption' => $model['caption']];
            }
            $controllers = array_merge($module['controllers'], $controllers);

            //根据 controller 来生成菜单索引
            foreach ($controllers as $controller) {
                $items .= "\t\t\t\t['title' => '{$controller['caption']}', 'url' => '{$module['name']}/{$controller['name']}/index', 'icon' => 'fa-folder',]," . PHP_EOL;
            }
            $items .= "\t\t\t\t]" . PHP_EOL;
            $items .= "\t\t\t]," . PHP_EOL;
        }
        $items .= "\t\t]" . PHP_EOL;
        $items .= "\t]";
        $this->content = TemplateHelper::parseTemplateTags(['ITEMS' => $items], $this->params['template']);
        return $this;
    }
}
{'fraction_non_alphanumeric': 0.21598968407479047, 'fraction_numerical': 0.0, 'mean_word_length': 2.3045793397231096, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '5649367', 'n_tokens_mistral': 1021, 'n_tokens_neox': 1039, 'n_words': 184}