2009年1月27日星期二

Re: [fw-mvc] placeholder versus $this->view->layout()

For a simple variable like in your example, using $this->view->layout()->food is fine.

But if you need to aggregate many items like in an array, using a placeholder is better, because you don't have to check if the array has already been created:

$this->view->placeholder("food")->append("burrito");

vs:

if (!isset($this->view->layout()->food) {
    $this->view->layout()->food = array();
}
$this->view->layout()->food[] = "burrito";

-Hector


On Tue, Jan 27, 2009 at 10:11 AM, Ed Lazor <edlazor@internetarchitects.biz> wrote:
Is there benefit to using one of these approaches over the other from
within an action method?

$this->view->placeholder("food")->set("burrito");

$this->view->layout()->food = "burrito";

Thanks,
Ed


没有评论: