Zend Framework - 对我的方法的调用去哪里?模型控制器?

发布于 2024-09-04 02:46:00 字数 1087 浏览 6 评论 0原文

我对我的控制器中应该有什么以及我的方法中应该有什么感到困惑。

具体来说,我在操作方法中有这个:

  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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剑心龙吟 2024-09-11 02:46:00

第二条路是要走的路。控制器在这里只是(主要)从模型获取一些数据并将其传递给视图。您所有的业务逻辑都应该进入模型。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文