module construct, add some templates
This commit is contained in:
@ -534,6 +534,7 @@ class ModuleService
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/controllers");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/migrations");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/service");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/models");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/models/forms");
|
||||
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/routs");
|
||||
@ -578,7 +579,7 @@ class ModuleService
|
||||
file_put_contents(APP_DIR . '/modules/' . $slug . '/controllers/' . ucfirst($slug) . 'Controller.php', $data );
|
||||
}
|
||||
|
||||
public function createRouts(string $slug): void
|
||||
public function createRoutes(string $slug): void
|
||||
{
|
||||
$data = file_get_contents(KERNEL_DIR . '/templates/routs/kernel_routs_template');
|
||||
$data = str_replace('{slug}', $slug, $data);
|
||||
@ -621,4 +622,43 @@ class ModuleService
|
||||
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/models/forms/Create' . ucfirst($slug) . 'Form.php', $data);
|
||||
}
|
||||
|
||||
public function createService(string $slug): void
|
||||
{
|
||||
$data = file_get_contents(KERNEL_DIR . '/templates/services/service_template');
|
||||
$data = str_replace('{slug}', $slug, $data);
|
||||
$data = str_replace('{model}', ucfirst($slug), $data);
|
||||
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/service/' . ucfirst($slug) . 'Service.php', $data);
|
||||
}
|
||||
|
||||
public function createViews(string $slug): void
|
||||
{
|
||||
$this->createIndex($slug);
|
||||
$this->createView($slug);
|
||||
$this->createForm($slug);
|
||||
}
|
||||
|
||||
public function createIndex(string $slug): void
|
||||
{
|
||||
$data = file_get_contents(KERNEL_DIR . '/templates/views/index_template');
|
||||
$data = str_replace('{slug}', $slug, $data);
|
||||
$data = str_replace('{model}', ucfirst($slug), $data);
|
||||
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/index.php', $data);
|
||||
}
|
||||
|
||||
public function createView(string $slug): void
|
||||
{
|
||||
$data = file_get_contents(KERNEL_DIR . '/templates/views/view_template');
|
||||
$data = str_replace('{slug}', $slug, $data);
|
||||
$data = str_replace('{model}', ucfirst($slug), $data);
|
||||
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/view.php', $data);
|
||||
}
|
||||
|
||||
public function createForm(string $slug): void
|
||||
{
|
||||
$data = file_get_contents(KERNEL_DIR . '/templates/views/form_template');
|
||||
$data = str_replace('{slug}', $slug, $data);
|
||||
$data = str_replace('{model}', ucfirst($slug), $data);
|
||||
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/form.php', $data);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user