43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace lib\Controllers;
|
|
|
|
use lib\Services\DefenceService;
|
|
use lib\Utils\Pagination;
|
|
|
|
class DefenceController extends DBMSController
|
|
{
|
|
private ?DefenceService $_clientService = null;
|
|
public function __construct(array $params = [])
|
|
{
|
|
parent::__construct($params);
|
|
$this->getView()->setPath('defence');
|
|
} //
|
|
public function getDefenceService(): DefenceService
|
|
{
|
|
if ($this->_clientService === null) {
|
|
$this->_clientService = new DefenceService();
|
|
}
|
|
return $this->_clientService;
|
|
}
|
|
|
|
//방어 defense_index.php
|
|
//CLI 접속방법 : php index.php site/defence/index/zone/존/parent/부모키/child/자식키
|
|
//WEB 접속방법 : http://localhost/site/defence/index/zone/존/parent/부모키/child/자식키
|
|
public function index(): string
|
|
{
|
|
$zone = $this->request->get('zone');
|
|
if (!$zone) {
|
|
throw new \Exception("zone 값이 정의되지 않았습니다.");
|
|
}
|
|
$this->zone = urldecode($zone);
|
|
$this->getDefenceService()->getModel()->where(['zone' => $this->zone]);
|
|
$this->getDefenceService()->getModel()->orderBy(['zone' => 'asc', 'parents' => 'asc', 'child' => 'asc']);
|
|
$this->curPage = intval($this->request->get('curPage', 1));
|
|
$this->perPage = intval($this->request->get('perPage', VIEW_LIST_PERPAGE));
|
|
[$this->total, $this->entities] = $this->getDefenceService()->getList($this->curPage, $this->perPage);
|
|
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
|
|
return $this->render(__FUNCTION__);
|
|
}
|
|
} //Class
|