Skip to content

Commit

Permalink
TLink: Try to create presenter link when there is a colon in the link…
Browse files Browse the repository at this point in the history
… string
  • Loading branch information
paveljanda committed Jan 12, 2018
1 parent f884084 commit 67daa82
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Traits/TLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Ublaboo\DataGrid\Traits;

use Nette;
use Nette\Application\UI\InvalidLinkException;
use Nette\Application\UI\Presenter;
use Ublaboo\DataGrid\DataGrid;
Expand All @@ -31,14 +32,24 @@ protected function createLink(DataGrid $grid, $href, $params)
{
$targetComponent = $grid;

if (strpos($href, ':') !== false) {
return $grid->getPresenter()->link($href, $params);
}

for ($iteration = 0; $iteration < 10; $iteration++) {
$targetComponent = $targetComponent->getParent();

if ($targetComponent === null) {
$this->throwHierarchyLookupException($grid, $href, $params);
}

try {
@$link = $targetComponent->link($href, $params);

} catch (InvalidLinkException $e) {
$link = false;
} catch (Nette\InvalidArgumentException $e) {
$link = false;
}

if ($link) {
Expand Down

0 comments on commit 67daa82

Please sign in to comment.