ビュー

ビューのメソッド

<?php
 // ビューにデータを渡す
$this->set('color', 'pink');

// ビューのヘルパーやテーマをカスタマイズする
$this->viewBuilder()
    ->setLayout('admin')
    ->helpers(['MyCustom'])
    ->theme('Modern')
    ->className('Modern.Admin');

// ビューファイルのレンダリング
$this->render('custom_file');

// リダイレクト
$this->redirect(['controller' => 'Users', 'action' => 'new']);
$this->redirect(['controller' => 'Users', 'action' => 'creare', $user]); // データを渡す

// 追加のモデル読み込み
$this->loadModel('Article'); // コントローラのデフォルト以外のモデルを使う

// コンポーネント読み込みの設定
public function initialize()
{
    parent::initialize();
    $this->loadComponent('Csrf'); // コンポーネント読み込み
    $this->loadComponent('Comments', Configure::read('Comments'));
}
?>