Feature #3997

Enable bulk assignment of template variables

Added by Robert Lemke about 10 years ago. Updated almost 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
Core
Target version:
Start date:
2009-07-27
Due date:
% Done:

100%

Has patch:

Description

Currenly TemplateView::assign() expects two arguments: the key and the value of the variable to assign. When lots of variables are assigned this is not convenient - a signature for bulk assignments would help.

Enhance assign() so that if the first argument is an array, the function assumes that it is an array of keys and values which will be assigned. In that case the second argument must not be set (and if so, results in an exception).


$this->view->assign('foo', 'bar');
$this->view->assign('baz', 'quux');

// same as:

$this->view->assign(array('foo' => 'bar', 'baz' => 'quux');

Associated revisions

Revision bf0a33ad (diff)
Added by Bastian Waidelich about 10 years ago

[+FEATURE] FLOW3 (MVC): Enable bulk assignment of template variables in AbstractView. Just call $this->view->assignMultiple(array('key1' => 'value1', 'key2' => 'value2')) to set multiple keys at once. Resolves #3997
[+BUGFIX] FLOW3 (MVC): AbstractView::assign() now returns itself as stated in the comment. This enables method chaining like: $this->view->assign('key1', 'value1')->assign('key2', 'value2');
[+TASK]: FLOW3 (MVC): Tweaked NotFoundView and StandardView and added test cases for all views of the FLOW3 MVC Subpackage.
[-TASK]: Fluid (View): Removed obsolete Method assign() from TemplateView as this method already exists in the parent class. The check for the key "view" is not needed anymore since the view is stored in the VariableContainer

History

#1 Updated by Bastian Waidelich about 10 years ago

  • Assignee changed from Sebastian Kurfuerst to Bastian Waidelich

#2 Updated by Bastian Waidelich about 10 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r2899.

Also available in: Atom PDF