forked from contributte/menu-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed dependency on Nette Application
- Loading branch information
1 parent
33d453c
commit 13d3cd4
Showing
15 changed files
with
156 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
namespace Carrooi\Menu; | ||
|
||
use Nette\Application\UI\Presenter; | ||
|
||
/** | ||
* @author David Kudera <[email protected]> | ||
*/ | ||
|
@@ -25,4 +27,10 @@ public function getSitemapTemplate(): string; | |
|
||
public function getPath(): array; | ||
|
||
|
||
public function getActivePresenter(): ?Presenter; | ||
|
||
|
||
public function setActivePresenter(?Presenter $link): void; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
namespace Carrooi\Menu\LinkGenerator; | ||
|
||
use Carrooi\Menu\IMenuItem; | ||
use Nette\Application\Application; | ||
use Nette\Application\LinkGenerator; | ||
|
||
/** | ||
* @author David Kudera <[email protected]> | ||
|
@@ -14,20 +14,20 @@ final class NetteLinkGenerator implements ILinkGenerator | |
{ | ||
|
||
|
||
/** @var \Nette\Application\Application */ | ||
private $application; | ||
/** @var \Nette\Application\LinkGenerator */ | ||
private $linkGenerator; | ||
|
||
|
||
public function __construct(Application $application) | ||
public function __construct(LinkGenerator $linkGenerator) | ||
{ | ||
$this->application = $application; | ||
$this->linkGenerator = $linkGenerator; | ||
} | ||
|
||
|
||
public function link(IMenuItem $item): string | ||
{ | ||
if (($action = $item->getAction()) !== null) { | ||
return $this->application->getPresenter()->link($action, $item->getActionParameters()); | ||
return $this->linkGenerator->link($action, $item->getActionParameters()); | ||
|
||
} elseif (($link = $item->getLink()) !== null) { | ||
return $link; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use Carrooi\Menu\IMenu; | ||
use Carrooi\Menu\MenuContainer; | ||
use Nette\Application\UI\Control; | ||
use Nette\Application\UI\Presenter; | ||
|
||
/** | ||
* @author David Kudera <[email protected]> | ||
|
@@ -60,4 +61,21 @@ public function renderType(IMenu $menu, string $menuTemplate): void | |
$this->template->render(); | ||
} | ||
|
||
|
||
/** | ||
* This method will be called when the component (or component's parent) | ||
* becomes attached to a monitored object. Do not call this method yourself. | ||
* @param \Nette\ComponentModel\IComponent | ||
* @return void | ||
*/ | ||
protected function attached($presenter) | ||
{ | ||
if ($presenter instanceof Presenter) { | ||
$menu = $this->container->getMenu($this->menuName); | ||
$menu->setActivePresenter($presenter); | ||
} | ||
|
||
parent::attached($presenter); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.