天天看点

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>