天天看點

Yii2 了解Controller

<a href="#1-%e7%89%88%e6%9c%ac">版本</a>

<a href="#2-%e7%bb%a7%e6%89%bf%e4%b8%8e%e5%ae%9e%e7%8e%b0">繼承與實作</a>

<a href="#3-actions">actions</a>

<a href="#4-createaction">createaction</a>

<a href="#5-getmodules">getmodules</a>

<a href="#6-runaction">runaction</a>

<a href="#7-run">run</a>

<a href="#8-findlayoutfile">findlayoutfile</a>

<a href="#9-render-rendercontent">render rendercontent</a>

<a href="#10-%e5%8f%82%e8%80%83">參考</a>

controller繼承與component, 并實作了viewcontextinterface接口。

在controller重要的有兩塊: action, view

在自定義的xxcontroller類中可以看見各種actionxxx函數,比如actionindex, actioncreate

而actions用于添加額外的action函數,如果有需要,派生類可以重載它:

這樣,隻要再添加view/xx/error.php 就可以使用這個action了。

該函數傳回其主人,主人的主人…的組合

以下連結中也有很多好東西:

<a href="http://www.yiifans.com/forum.php?mod=viewthread&amp;tid=60">http://www.yiifans.com/forum.php?mod=viewthread&amp;tid=60</a>