生成
@author nash.tang <112614251@qq.com>

@param $group
@param $module
@param $model
@param string $type
@param string $mode
@param string $output
@param string $file
@param string $customTemplate
766626
public function run($group, $module, $model, $type = "", $mode = "default", $output = "view", $file = "", $customTemplate = "")
    {
        switch ($type)
        {
            case "controller":
                $this->generateController($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRoute($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "model":
                $this->generateModel($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "repository":
                $this->generateRepository($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            case "view":
                $this->generateView($group, $module, $model, $mode, $output, $file, $customTemplate);
                break;
            default:
                $this->generateController($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRoute($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateModel($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateRepository($group, $module, $model, $mode, $output, $file, $customTemplate);
                $this->generateView($group, $module, $model, $mode, $output, $file, $customTemplate);
        }
    }
454835
public function handle(Input $input, Output $output)
    {
        $module = $input->getArgument('module');

        try {
            if (!class_exists("{$module}\\{$module}")) throw new \Exception("Error: Module {$module} is not exist", 1);

            $reflector = new \ReflectionClass("{$module}\\{$module}");
            $templates = dirname(dirname($reflector->getFileName())) . "/templates";

            $this->createBaseTemplate(get_files("{$templates}/base"));
            $this->createAppTemplate(get_files("{$templates}/app"));
            $this->createAssetSassTemplate(get_files("{$templates}/assets/sass"));
            $this->createAssetJsTemplate(get_files("{$templates}/assets/js"));
            $this->createConfigTemplate(get_files("{$templates}/config"));
            $this->createDbMigrationTemplate(get_files("{$templates}/db/migrations"));
            $this->createDbSeederTemplate(get_files("{$templates}/db/seeds"));
            $this->createViewTemplate(get_files("{$templates}/views"));
        } catch (\Exception $e) {
            $output->writeln($e->getMessage());
        }
    }
449264
public function renderModuleTemplate(Project $project, ModuleTemplate $template, $module, $path)
    {
        $template->setModule($module);
        $template->setProject($project);

        $fileCollection = new FileCollection();

        $modulePath = $path . $template->getPath();

        $moduleName = $template->getFilename();

        $file = new File($modulePath, $moduleName, $template->render());
        $file->setAddToFile(true);

        $fileCollection->add($file);

        return $fileCollection;
    }
1169767
private function setByTypeFile(string $module, array $fields) : void
    {
        foreach ($fields as $field) {
            $this->setByTypeFileField($field);
        }
    }
125613
private function createModuleModels($module, $path)
    {
        $module_path = $path . $module;
        $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path);

        $configGenerator = $this->getConfigGenerator($module_path);

        $this->buildModels($configGenerator);
        $this->buildSql($configGenerator);

        $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array(
            "module" => $module,
        ));
        $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" .
            DIRECTORY_SEPARATOR . "config.php", true);
        $this->log->addLog("Generado config genérico para propel");
    }
992962
private static function log($type, $message, $trace, $groupIdentifier)
    {
        $hashArray = static::getHashArray($message, $groupIdentifier);
        
        $file = 'unknown';
        $line = 'unknown';
        $fn = 'unknown';
        $fnArgs = [];
        
        if (isset($trace[0])) {
            $file = !isset($trace[0]['file']) ? : $trace[0]['file'];
            $line = !isset($trace[0]['line']) ? : $trace[0]['line'];
            $fn = !isset($trace[0]['function']) ? : $trace[0]['function'];
            $fnArgs = !isset($trace[0]['args']) ? : $trace[0]['args'];
        }
        
        if (isset($trace[1])) {
            $fn = !isset($trace[1]['function']) ? : $trace[1]['function'];
            $fnArgs = !isset($trace[1]['args']) ? : $trace[1]['args'];
        }
        
        if ($message instanceof Arrayable) {
            $message = $message->toArray();
        }
        
        $model = new self();
        $model->attributes = [
            'time' => time(),
            'message' => is_array($message) ? Json::encode($message) : $message,
            'type' => $type,
            'trace_file' => $file,
            'trace_line' => $line,
            'trace_function' => $fn,
            'trace_function_args' => Json::encode($fnArgs),
            'get' => (isset($_GET)) ? Json::encode($_GET) : '{}',
            'post' => (isset($_POST)) ? Json::encode($_POST) : '{}',
            'session' => (isset($_SESSION)) ? Json::encode($_SESSION) : '{}',
            'server' => (isset($_SERVER)) ? Json::encode($_SERVER) : '{}',
            'group_identifier' => $hashArray['hash'],
            'group_identifier_index' => $hashArray['index'],
        ];
        
        return $model->save(false);
    }
375559
public function defaultTemplate ($module, $controller, $action)
	{
		
		// Start template path with the controller module
		
		$template	= $module? $module . '/' : '';
		
		// If theres a controller then add it
		
		if ($controller)
		{
		
			// Split controller and remove the final block if its Index

			$arrController	= explode ('\\', $controller);
			$pop = strtolower (array_pop ($arrController));
			
			if ($pop != 'index')
			{
				$arrController[] = $pop;
			}

			$template	.= join ('/', $arrController) . '/';
				
		}
		
		// Remove initial /
		
		if ($template[0] == '/')
		{
			$template	= substr ($template, 1);
		}
		
		// If there is no template file yet just use the action
		
		$template	.= $action;
		
		// Lowercase and add tpl extension
		
		$template	= strtolower ($template) . '.tpl';
		
		// Return template
		
		return $template;
		
	}
29560
public static function output(ViewModel $viewmodel) {

		$viewmodel -> assign(static :: getVariables());

		$template = new Template($viewmodel);
		
		$template -> setDirectory(Path :: get('cache-template'));
		$template -> render();
		
		$file = $template -> getFile() -> entity() -> getBasepath();

		echo $viewmodel -> getView() -> process($file) -> getOutput();
	}
24698
public function generateChildDef(&$def, $module)
    {
        if (!empty($def->child)) { // already done!
            return;
        }
        $content_model = $def->content_model;
        if (is_string($content_model)) {
            // Assume that $this->keys is alphanumeric
            $def->content_model = preg_replace_callback(
                '/\b(' . implode('|', $this->keys) . ')\b/',
                array($this, 'generateChildDefCallback'),
                $content_model
            );
            //$def->content_model = str_replace(
            //    $this->keys, $this->values, $content_model);
        }
        $def->child = $this->getChildDef($def, $module);
    }
1241598
public function create($key, $value, $group = Manager::DEFAULT_GROUP)
    {
        return $this->createModel()->create([
            'key' => $key,
            'value' => $value,
            'group' => $group,
        ]);
    }
574940
public function loadBladeTemplate($view, $module, array $args = array())
    {
        \Modularity\Helper\File::maybeCreateDir(MODULARITY_CACHE_DIR);

        if (!$module->templateDir) {
            throw new \LogicException('Class ' . get_class($module) . ' must have property $templateDir');
        }

        $template = \Modularity\Helper\Template::getModuleTemplate($view, $module);
        $templatePath = trailingslashit(dirname($template));
        $view = basename($template, '.blade.php');
        $view = basename($view, '.php');

        if (\Modularity\Helper\Template::isBlade($template)) {
            $blade = new Blade($templatePath, MODULARITY_CACHE_DIR);
            return $blade->view()->make($view, $module->data)->render();
        }

        return $this->loadTemplate($template, $module, $args);
    }
1047337
public function hasAuthorization($module, $action, GroupInterface $group)
    {
        $queryBuilder = $this->createQueryBuilder('mag');

        $queryBuilder->select('mag.id');

        $queryBuilder->innerJoin('mag.group', 'g');
        $queryBuilder->innerJoin('mag.module', 'm');
        $queryBuilder->innerJoin('mag.moduleActions', 'ma');

        $queryBuilder->andWhere(
            $queryBuilder->expr()->eq('m.slug', ':module')
        );

        $queryBuilder->andWhere(
            $queryBuilder->expr()->eq('ma.identifier', ':action')
        );

        $queryBuilder->andWhere(
            $queryBuilder->expr()->eq('mag.group', ':group')
        );

        $queryBuilder->andWhere(
            $queryBuilder->expr()->eq('mag.enabled', ':enabled')
        );

        $queryBuilder->setParameter('module', $module);
        $queryBuilder->setParameter('action', $action);
        $queryBuilder->setParameter('group', $group);
        $queryBuilder->setParameter('enabled', true);

        $helper = new UtilsHelper();
        $resultCacheId = $helper->generateNameForCache($module, $action, $group);

        return $queryBuilder
            ->getQuery()
            ->useResultCache(true, 3600, $resultCacheId)
            ->getOneOrNullResult()
        ;
    }
502966
public function generateRepository($group, $module, $model, $mode, $output, $file = "", $customTemplate = "")
    {
        $generator = new RepositoryGenerator($group, $module, $model, $mode, $output, $file, $customTemplate);
        $generator->run();
    }
589477
public function createFromTemplate($template)
    {
        $parameter = new GroupParameter();
        $parameter->setName($template->name);
        $parameter->setTemplate($template);
        if ($template->type == GroupParameterType::HASHTABLE && isset($template->entries)) {
            $parameter->setChildren($this->createRequiredFromTemplates($template->entries));
        } elseif ($template->type != GroupParameterType::HASHTABLE && $template->type != GroupParameterType::EDITABLE_HASHTABLE) {
            if ($template->type == GroupParameterType::BOOLEAN) {
                $value = true;
            } else {
                $value = empty($template->values) ? '' : $template->values[0];
            }
            $parameter->addValue($value);
        }
        return $parameter;
    }
725080
public static function renderModule($module, $attribs = array())
    {
        $event = new BeforeRenderModuleEvent($module, $attribs);
        self::$eventDispatcher->dispatch('joomla.before_render_module', $event);

        $module = $event->getModule();
        $attribs = $event->getAttribs();

        if ($event->getContent() !== null) {
            return $event->getContent();
        }

        $content = parent::renderModule($module, $attribs);

        $event = new AfterRenderModuleEvent($module, $attribs, $content);
        self::$eventDispatcher->dispatch('joomla.after_render_module', $event);

        return $event->getContent();
    }
301774
public function create($title, $tag = null, $group = null, $description = null) {
        $params = [
            'data' => [
                'title' => $title
            ]
        ];

        if (isset($tag)) {
            $params['data']['tag'] = $tag;
        }

        if (isset($group)) {
            $params['data']['group'] = $group;
        }

        if (isset($group)) {
            $params['data']['description'] = $description;
        }

        $result = $this->api->request(
            'checkmk.statictag.create',
            $params
        );

        if (!array_key_exists('id', $result) ||
            !is_numeric($result['id']) ||
            !array_key_exists('success', $result) ||
            $result['success'] !== true) {
            if (array_key_exists('message', $result)) {
                throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
            } else {
                throw new RuntimeException('Bad result');
            }
        }

        return (int) $result['id'];
    }
1348808
public function generateController($group, $module, $model, $mode, $output, $file = "", $customTemplate = "")
    {
        $generator = new ControllerGenerator($group, $module, $model, $mode, $output, $file, $customTemplate);
        $generator->run();
    }