This commit is contained in:
2023-04-11 16:43:52 +08:00
parent 47ab82628b
commit 921863865d
2 changed files with 12 additions and 4 deletions
+10
View File
@@ -64,6 +64,16 @@ abstract class GiiBase
$this->modelNamespace = $modelNamespace;
}
/**
* @param string $content
* @return string
*/
protected function clearBlank(string $content): string
{
return preg_replace('/\s/ixm', '', $content);
}
/**
* @param string $controllerPath
*/
+1 -3
View File
@@ -129,11 +129,9 @@ use {$model_namespace}\\{$managerName};
file_put_contents($file, '<?php' . PHP_EOL);
file_put_contents($file, PHP_EOL, FILE_APPEND);
file_put_contents($file, PHP_EOL, FILE_APPEND);
file_put_contents($file, PHP_EOL, FILE_APPEND);
file_put_contents($file, 'use Kiri\Message\Handler\Router;' . PHP_EOL, FILE_APPEND);
file_put_contents($file, PHP_EOL, FILE_APPEND);
file_put_contents($file, PHP_EOL, FILE_APPEND);
file_put_contents($file, PHP_EOL, FILE_APPEND);
}
$tableName = str_replace($this->db->tablePrefix, '', $this->tableName);
@@ -150,7 +148,7 @@ use {$model_namespace}\\{$managerName};
Router::get(\'detail\', \'' . $controllerName . 'Controller@actionDetail\');
});
';
if (!str_contains(preg_replace('/\s/ixm', '', file_get_contents($file)), preg_replace('/\s/ixm', '', $addRouter))) {
if (!str_contains($this->clearBlank(file_get_contents($file)), $this->clearBlank($addRouter))) {
file_put_contents($file, $addRouter, FILE_APPEND);
}