-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow passing objects to the url helper #4178
Allow passing objects to the url helper #4178
Conversation
@@ -93,6 +96,15 @@ public function __invoke($name = null, array $params = array(), $options = array | |||
} | |||
} | |||
|
|||
try { | |||
|
|||
$params = ArrayUtils::iteratorToArray($params, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this. Check to see if $params
is Traversable
, and only then do the iteratorToArray()
call. This will eliminate the need for the catch and re-throw.
Ideally this should be in the router, not the |
Of course, changing it in |
Expect an update within the hour need to finish some other stuff on my mind |
); | ||
|
||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all the empty lines here at the beginning of each block?
if (!is_array($params)) { | ||
if (!$params instanceof Traversable) { | ||
throw new Exception\InvalidArgumentException( | ||
'Params is expected to be an array of a Traversable object' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/of/or/
…port Allow passing objects to the url helper Conflicts: library/Zend/View/Helper/Url.php
…eature/url-helper-model-support Allow passing objects to the url helper Conflicts: library/Zend/View/Helper/Url.php
Heya peeeps!
I can't be the only person that hates doing
since they map directly it would be nice to just do
An idea would also be to check if the model/entity has a toArray method if the ArrayUtils fails.