Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update route #562

Open
wants to merge 7 commits into
base: 4.5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"require": {
"php": ">=7.4",
"codeigniter/framework": "^3",
"luthier/luthier": "^1.0",
"vlucas/phpdotenv": "^5.5"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Rilis: __belum rilis__
## :rocket: Peningkatan
- Hapus `index.php` dari url
- Pengecekan sudah install atau belum kini dilakukan secara global, tidak hanya pada main
- Peningkataan penggunaan route
- Pengelompokan view

## :hammer_and_wrench: Perbaikan

Expand Down
2 changes: 1 addition & 1 deletion donjo-app/Views/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<hr>
<div style="width:400px;margin:0px auto;">
<h4>Klik “Lanjut” untuk memulai proses instalasi database SID. Proses instalasi memerlukan waktu singkat. Setelah selesai, Anda akan mendapatkan “username” dan “password”. Catat/simpan “username” dan “password” sebelum meneruskan ke langkah selanjutnya.</h4><br>
<a href="<?php echo site_url('install/run') ?>" class="uibutton special">Lanjut</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?php echo site_url(route_to('install.run')) ?>" class="uibutton special">Lanjut</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
</div>
</body>
Expand Down
2 changes: 2 additions & 0 deletions donjo-app/config/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
'filepath' => 'hooks',
'params' => [],
];

$hook = Luthier\Hook::getHooks();
2 changes: 2 additions & 0 deletions donjo-app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@
$route['default_controller'] = 'main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = false;

$route = Luthier\Route::getRoutes();
20 changes: 20 additions & 0 deletions donjo-app/controllers/LuthierController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Luthier default controller - DO NOT EDIT OR REMOVE THIS FILE!
*
* Because CodeIgniter checks the existence of the file/class/method of the controller
* pointed in all our routes, this allows to create dynamic routes without hacking/extending
* the CI_Router class.
*/
defined('BASEPATH') || exit('No direct script access allowed');

class LuthierController extends CI_Controller
{
/**
* Luthier CI fake index method
*/
public function index()
{
}
}
16 changes: 8 additions & 8 deletions donjo-app/controllers/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ public function index()
}
}

/**
* View halaman install
*
* @return string
*/
public function initial()
{
view('install');
return view('install/index');
}

public function install()
Expand All @@ -55,15 +60,10 @@ public function install()
$out = $install->run();

if (null === $out) {
redirect('/');
redirect(route_to('index'));
}

view('init', $out);
}

public function init($out = null)
{
view('init', $out);
view('install/done', $out);
}

public function auth()
Expand Down
23 changes: 22 additions & 1 deletion donjo-app/helpers/donjolib_helper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
<?php

if (! function_exists('url_to')) {
function url_to(string $route_name, ...$args): string
{
return route($route_name, $args);
}
}

if (! function_exists('route_to')) {
function route_to(string $route_name, ...$args)
{
$route = route($route_name, $args);
$urlParts = parse_url($route);

if ($urlParts !== false && isset($urlParts['path'])) {
return $urlParts['path'];
}

return $route;
}
}

if (! function_exists('view')) {
/**
* fungsi view() untuk menggantikan $this->load->view()
Expand All @@ -8,7 +29,7 @@ function view(string $view, array $data = [], bool $return = false)
{
$CI = &get_instance();

$CI->load->view($view, $data, $return);
return $CI->load->view($view, $data, $return);
}
}

Expand Down
7 changes: 7 additions & 0 deletions donjo-app/routes/api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

/**
* API Routes
*
* This routes only will be available under AJAX requests. This is ideal to build APIs.
*/
13 changes: 13 additions & 0 deletions donjo-app/routes/cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* CLI Routes
*
* This routes only will be available under a CLI environment
*/

// To enable Luthier-CI built-in cli commands
// uncomment the followings lines:

// Luthier\Cli::maker();
// Luthier\Cli::migrations();
8 changes: 8 additions & 0 deletions donjo-app/routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

Route::get('/', 'main@index')->name('index');

Route::group('install', static function () {
Route::get('/', 'main@initial')->name('install.view');
Route::get('run', 'main@install')->name('install.run');
});