Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Issue #77: Do not pass template object to the helper
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed May 3, 2016
1 parent 4972e70 commit efda0e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion code/template/behavior/helperable.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ public function invokeHelper($identifier, $params = array())
$params = array_merge($this->getParameters()->toArray(), $params);
}

return $helper->$function($params, $this->getMixer());
return $helper->$function($params);
}
}
14 changes: 7 additions & 7 deletions code/template/helper/actionbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TemplateHelperActionbar extends TemplateHelperAbstract
* @param array $config An optional array with configuration options
* @return string Html
*/
public function render($config = array(), TemplateInterface $template)
public function render($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
Expand All @@ -44,9 +44,9 @@ public function render($config = array(), TemplateInterface $template)
$name = $command->getName();

if(method_exists($this, $name)) {
$html .= $this->$name(ObjectConfig::unbox($command), $template);
$html .= $this->$name(ObjectConfig::unbox($command));
} else {
$html .= $this->command(ObjectConfig::unbox($command), $template);
$html .= $this->command(ObjectConfig::unbox($command));
}
}
$html .= '</div>';
Expand All @@ -62,7 +62,7 @@ public function render($config = array(), TemplateInterface $template)
* @param array $config An optional array with configuration options
* @return string Html
*/
public function command($config = array(), TemplateInterface $template)
public function command($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
Expand Down Expand Up @@ -100,7 +100,7 @@ public function command($config = array(), TemplateInterface $template)

//Create the href
if(!empty($config->href)) {
$config->attribs['href'] = $template->route($config->href);
$config->attribs['href'] = $config->href;
}

$html = '<a '.$this->buildAttributes($config->attribs).'>';
Expand Down Expand Up @@ -134,10 +134,10 @@ public function separator($config = array())
* @param array $config An optional array with configuration options
* @return string Html
*/
public function dialog($config = array(), TemplateInterface $template)
public function dialog($config = array())
{
$html = $this->createHelper('behavior')->modal();
$html .= $this->command($config, $template);
$html .= $this->command($config);

return $html;
}
Expand Down
13 changes: 6 additions & 7 deletions code/template/helper/listbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TemplateHelperListbox extends TemplateHelperSelect
* @return string Html
* @see __call()
*/
public function render($config = array(), TemplateInterface $template)
public function render($config = array())
{
$config = new ObjectConfig($config);
$config->append(array(
Expand Down Expand Up @@ -62,9 +62,9 @@ public function render($config = array(), TemplateInterface $template)
}

if($config->autocomplete) {
$result = $this->__autocomplete($config, $template);
$result = $this->__autocomplete($config);
} else {
$result = $this->__listbox($config, $template);
$result = $this->__listbox($config);
}

return $result;
Expand Down Expand Up @@ -251,7 +251,7 @@ public function timezones($config = array())
* @return string Html
* @see __call()
*/
private function __listbox($config = array(), TemplateInterface $template)
private function __listbox($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
Expand Down Expand Up @@ -316,7 +316,7 @@ private function __listbox($config = array(), TemplateInterface $template)
* @param array|ObjectConfig $config
* @return string The html output
*/
private function __autocomplete($config = array(), TemplateInterface $template)
private function __autocomplete($config = array())
{
$config = new ObjectConfigJson($config);
$config->append(array(
Expand Down Expand Up @@ -352,11 +352,10 @@ private function __autocomplete($config = array(), TemplateInterface $template)
$parts = array_merge($parts, ObjectConfig::unbox($config->filter));
}

$config->url = $template->route($parts, false, false);
$config->url = $this->getObject('lib:dispatcher.router.route')->setQuery($parts);
}

$html = '';

$html .= $this->createHelper('behavior')->autocomplete($config);

$config->attribs->name = $config->name;
Expand Down

0 comments on commit efda0e3

Please sign in to comment.