42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
/**
|
|
* 구 관리자 업무 URL(admin/…) → 메인 사이트 업무 URL(bag/…) 영구 이전.
|
|
* POST 폼은 307로 메서드·본문 유지를 시도하고, GET 은 301.
|
|
*/
|
|
class WorkMovedToBag extends BaseController
|
|
{
|
|
public function toBag(string $prefix, string $rest = ''): \CodeIgniter\HTTP\RedirectResponse
|
|
{
|
|
$rest = trim($rest, '/');
|
|
|
|
if ($prefix === 'packaging-units') {
|
|
$path = 'packaging-units/manage';
|
|
if ($rest !== '') {
|
|
$path .= '/' . $rest;
|
|
}
|
|
} else {
|
|
$path = $prefix;
|
|
if ($rest !== '') {
|
|
$path .= '/' . $rest;
|
|
}
|
|
}
|
|
|
|
$target = site_url('bag/' . $path);
|
|
$query = $this->request->getUri()->getQuery();
|
|
if ($query !== '') {
|
|
$target .= '?' . $query;
|
|
}
|
|
|
|
$code = $this->request->getMethod() === 'post' ? 307 : 301;
|
|
|
|
return redirect()->to($target)->setStatusCode($code);
|
|
}
|
|
}
|