nette / application

🏆 A full-stack component-based MVC kernel for PHP that helps you write powerful and modern web applications. Write less, have cleaner code and your work will bring you joy.

Home Page:https://doc.nette.org/application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: new method Link::isLinkCurrent()

MartkCz opened this issue · comments

I want check lazy link if is current, but I can't because of private $component

class TabsComponent {

    public function addLink(string $name, Link $link)

}

Solution is:

class Link {

    public function getComponent(): Component

}

or better

class Link {

    public function isLinkCurrent(): bool {
        return $this->component->isLinkCurrent($this->destination, $this->parameters);
    }

}

I'm willing to write a PR

$tabsComponent->isLinkCurrent($link->getDestination(), $link->getParameters()) would not work?

It doesn't work, when link is from presenter I must call $this->getPresenter() when from other component, I have to call $this['component']->isLinkCurrent(), but I don't know from which component link is created, because of private property $component

Code:

$this->lazyLink('this', ['type' => 'groups'])