|
|
|
@ -534,7 +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/services");
|
|
|
|
|
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/models");
|
|
|
|
|
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/models/forms");
|
|
|
|
|
mkdir(KERNEL_APP_MODULES_DIR . "/$slug/routs");
|
|
|
|
@ -545,120 +545,36 @@ class ModuleService
|
|
|
|
|
mkdir(APP_DIR . "/modules/$slug/routs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createManifest(array $params): void
|
|
|
|
|
public function createModuleByParams(array $params): void
|
|
|
|
|
{
|
|
|
|
|
$name = $params['name'] ?? '';
|
|
|
|
|
$author = $params['author'] ?? '';
|
|
|
|
|
$slug = $params['slug'] ?? '';
|
|
|
|
|
$slug = $params['slug'];
|
|
|
|
|
$model = $params['model'];
|
|
|
|
|
|
|
|
|
|
$data = "{\n";
|
|
|
|
|
$data .= " \"name\": \"$name\",\n";
|
|
|
|
|
$data .= " \"version\": \"0.1\",\n";
|
|
|
|
|
$data .= " \"author\": \"$author\",\n";
|
|
|
|
|
$data .= " \"slug\": \"$slug\",\n";
|
|
|
|
|
$data .= " \"description\": \"$name module\",\n";
|
|
|
|
|
$data .= " \"module_class\": \"app\\\\modules\\\\$slug\\\\" . ucfirst($slug) . "Module\",\n";
|
|
|
|
|
$data .= " \"module_class_file\": \"{APP}/modules/$slug/" . ucfirst($slug) . "Module.php\",\n";
|
|
|
|
|
$data .= " \"routs\": \"routs/$slug.php\",\n";
|
|
|
|
|
$data .= " \"migration_path\": \"migrations\"\n";
|
|
|
|
|
$data .= "}";
|
|
|
|
|
|
|
|
|
|
file_put_contents(APP_DIR . "/modules/$slug/manifest.json", $data);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/manifests/manifest_template', APP_DIR . "/modules/$slug/manifest.json", $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/controllers/kernel_controller_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/controllers/' . $model . 'Controller.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/controllers/app_controller_template', APP_DIR . '/modules/' . $slug . '/controllers/' . $model . 'Controller.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/routs/kernel_routs_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/routs/' . $slug . '.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/routs/app_routs_template', APP_DIR . '/modules/' . $slug . '/routs/' . $slug . '.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/module_files/kernel_module_file_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/' . $model . 'Module.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/module_files/app_module_file_template', APP_DIR . '/modules/' . $slug . '/' . $model . 'Module.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/models/model_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/models/' . $model . '.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/models/forms/create_form_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/models/forms/Create' . $model . 'Form.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/services/service_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/services/' . $model . 'Service.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/views/index_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/index.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/views/view_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/view.php', $params);
|
|
|
|
|
$this->createModuleFileByTemplate(KERNEL_TEMPLATES_DIR . '/views/form_template', KERNEL_APP_MODULES_DIR . '/' . $slug . '/views/form.php', $params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createControllers(string $slug): void
|
|
|
|
|
public function createModuleFileByTemplate(string $templatePath, string $filePath, array $params): void
|
|
|
|
|
{
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/controllers/kernel_controller_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/controllers/' . ucfirst($slug) . 'Controller.php', $data);
|
|
|
|
|
$data = file_get_contents($templatePath);
|
|
|
|
|
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/controllers/app_controller_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(APP_DIR . '/modules/' . $slug . '/controllers/' . ucfirst($slug) . 'Controller.php', $data );
|
|
|
|
|
}
|
|
|
|
|
$data = str_replace('{slug}', $params['slug'], $data);
|
|
|
|
|
$data = str_replace('{model}', $params['model'], $data);
|
|
|
|
|
$data = str_replace('{name}', $params['name'], $data);
|
|
|
|
|
$data = str_replace('{author}', $params['author'], $data);
|
|
|
|
|
|
|
|
|
|
public function createRoutes(string $slug): void
|
|
|
|
|
{
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/routs/kernel_routs_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/routs/' . $slug . '.php', $data);
|
|
|
|
|
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/routs/app_routs_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(APP_DIR . '/modules/' . $slug . '/routs/' . $slug . '.php', $data );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createModuleClassFiles(string $slug, string $label): void
|
|
|
|
|
{
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/module_files/kernel_module_file_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
$data = str_replace('{label}', $label, $data);
|
|
|
|
|
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/' . ucfirst($slug) . 'Module.php', $data);
|
|
|
|
|
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/module_files/app_module_file_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(APP_DIR . '/modules/' . $slug . '/' . ucfirst($slug) . 'Module.php', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createModel(string $slug): void
|
|
|
|
|
{
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/models/model_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
file_put_contents(KERNEL_APP_MODULES_DIR . '/' . $slug . '/models/' . ucfirst($slug) . '.php', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createFormModel(string $slug): void
|
|
|
|
|
{
|
|
|
|
|
$data = file_get_contents(KERNEL_DIR . '/templates/models/forms/create_form_template');
|
|
|
|
|
$data = str_replace('{slug}', $slug, $data);
|
|
|
|
|
$data = str_replace('{model}', ucfirst($slug), $data);
|
|
|
|
|
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);
|
|
|
|
|
file_put_contents($filePath, $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|