Skip to content

Commit

Permalink
Is possible add parameters into control in template
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Lauko committed Jun 30, 2017
1 parent c1d9d42 commit c183389
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DI/GoogleAnalyticsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function loadConfiguration()
public static function register(Nette\Configurator $configurator)
{
$configurator->onCompile[] = function ($config, Nette\DI\Compiler $compiler) {
$compiler->addExtension('googleAnalytics', new AppUtilsExtension());
$compiler->addExtension('googleAnalytics', new GoogleAnalyticsExtension());
};
}
}
13 changes: 10 additions & 3 deletions src/GoogleAnalyticsControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ public function __construct($code, $showLoggedUserId, User $user)
$this->showLoggedUserId = $showLoggedUserId === true;
}

public function render()
public function render($code = null, $showLoggedUserId = null)
{
$this->template->code = $this->code;
$this->template->code = $code !== null ? $code : $this->code;
$this->template->user = $this->user;
$this->template->showLoggedUserId = $this->showLoggedUserId && $this->user->isLoggedIn();

if ($showLoggedUserId !== null) {
$showUserId = $showLoggedUserId;
} else {
$showUserId = $this->showLoggedUserId;
}

$this->template->showLoggedUserId = $showUserId && $this->user->isLoggedIn();

$this->template->setFile(dirname(__FILE__) . '/templates/default.latte');
$this->template->render();
Expand Down

0 comments on commit c183389

Please sign in to comment.