Skip to content

Commit

Permalink
Allowing MvcModel::to_url() to optionally accept a second argument, $…
Browse files Browse the repository at this point in the history
…options
  • Loading branch information
tombenner committed Feb 29, 2012
1 parent 99210ef commit 127cdd3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/mvc_router.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ public function public_url($options=array()) {
$model = MvcModelRegistry::get_model($model_name);
if (!empty($model) && method_exists($model, 'to_url')) {
$url = site_url('/');
$url .= $model->to_url($options['object']);
$method = new ReflectionMethod(get_class($model), 'to_url');
$parameter_count = $method->getNumberOfParameters();
if ($parameter_count == 2) {
$url .= $model->to_url($options['object'], $options);
} else {
$url .= $model->to_url($options['object']);
}
return $url;
}
if (empty($options['id']) && !empty($options['object']->__id)) {
Expand Down

0 comments on commit 127cdd3

Please sign in to comment.