Zend Framework - 对我的方法的调用去哪里?模型控制器?
我对我的控制器中应该有什么以及我的方法中应该有什么感到困惑。
具体来说,我在操作方法中有这个:
public function upcomingshowsAction()
{
$gcal = $this->_validateCalendarConnection();
$uncleanedFeedArray = $this->_getCalendarFeed($gcal);
$finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray);
$this->view->googleArray = $finishedFeedArray;
}
然后(我知道是错误的),我的方法仍然在控制器的底部。
所以我想知道的是,对于即将到来的showsAction 方法中的那些方法,所有实际方法是否都应该在一个模型中,然后我会得到类似这样的东西:
public function upcomingshowsAction()
{
$finishedFeedArray = new Application_Model_calendarModelPage();
$this->view->googleArray = $finishedFeedArray;
}
然后在模型中出现类似的东西:
class Application_Model_CalendarModelPage
{
$gcal = $this->_validateCalendarConnection();
$uncleanedFeedArray = $this->_getCalendarFeed($gcal);
$finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray);
public functions
{
...
...
...
}
}
我在右边吗跟踪这里?
谢谢!
I'm confused about exactly what I should have in my controller and what in my method.
Specifically, I have this in the action method:
public function upcomingshowsAction()
{
$gcal = $this->_validateCalendarConnection();
$uncleanedFeedArray = $this->_getCalendarFeed($gcal);
$finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray);
$this->view->googleArray = $finishedFeedArray;
}
And then (incorrectly I know), I have my methods still in the bottom of my controller.
So what I'm wondering, is for those methods in the upcomingshowsAction method, should all the actual methods just be in one model and then I'd have something like this:
public function upcomingshowsAction()
{
$finishedFeedArray = new Application_Model_calendarModelPage();
$this->view->googleArray = $finishedFeedArray;
}
And then something like this in the model:
class Application_Model_CalendarModelPage
{
$gcal = $this->_validateCalendarConnection();
$uncleanedFeedArray = $this->_getCalendarFeed($gcal);
$finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray);
public functions
{
...
...
...
}
}
Am I on the right track here?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二条路是要走的路。控制器在这里只是(主要)从模型获取一些数据并将其传递给视图。您所有的业务逻辑都应该进入模型。
The second way is the way to go. The controller is here only (mostly) to get some data from the model and pass it to the view. All your business logic should go into the model.