Six_Cool's 작업창고

고도몰5 튜닝 컨트롤러 기본 : Data Handling, View Renderin 본문

프로젝트/고도몰튜닝

고도몰5 튜닝 컨트롤러 기본 : Data Handling, View Renderin

Six_Cool 2021. 7. 27. 11:15

아래 링크 참고 Data Handling, View Rendering

http://doc.godomall5.godomall.com/Learning_More/Controller

 

Controller - Godomall5

Controller Controller 실행 순서 controller는 framework의 구동을 제외한 솔루션의 기본 공통 작업부터 화면 출력까지의 업무를 관장합니다. view(템플릿 엔진) 설정 Setup() 해당 화면에서 사용될 interceptor 설

doc.godomall5.godomall.com

 

View Rendering                                              

view 출력 예제

<?php
namespace Bundle\Controller\[Front|Admin|Mobile]\Test;

class MyController extends \Controller\[Front|Admin|Mobile]\Controller {
    public function index() {
        // somecode or data handling				
    }
}

 

리다이렉트 예제

<?php
namespace Bundle\Controller\[Front|Admin|Mobile]\Test;

class MyController extends \Controller\[Front|Admin|Mobile]\Controller {
    public function index() {
        $this->redirect('../order/cart');
    }
}

 

JSON 출력 예제

<?php
namespace Bundle\Controller\[Front|Admin|Mobile]\Test;

class MyController extends \Controller\[Front|Admin|Mobile]\Controller {
    public function index() {
        // case 1
        $this->setData('wrapper', [
            'test1' => 1,
            'test2' => 2,
            'test3' => 3,
        ]);
        $this->json();

        // case 2
        $data = [
            'wrapper' => [
                'test1' => 1,
                'test2' => 2,
                'test3' => 3,
            ]
        ]);
        $this->json($data);
    }
}

 

파일 다운로드 예제

<?php
namespace Bundle\Controller\[Front|Admin|Mobile]\Test;

class MyController extends \Controller\[Front|Admin|Mobile]\Controller {
    public function index() {
        // 파일경로와 파일명을 인자로 넘기면 즉시 다운로드가 실행
        $this->download(UserFilePath::frontSkin('mera_ws','img','btn_19out.gif'), 'sample_test.gif');
    }
}

 

스트림 파일 다운로드 예제

<?php
namespace Bundle\Controller\[Front|Admin|Mobile]\Test;

class MyController extends \Controller\[Front|Admin|Mobile]\Controller {
    public function index() {
        $this->redirect('../order/cart');
    }
}

 

Comments