public function setReturnUrl($returnUrl, $params = []) { if (preg_match('~^([\\w:]+):(\\w*+)(#.*)?()\\z~', $returnUrl)) { $returnUrl = $this->linkGenerator->link($returnUrl, $params); } parent::setReturnUrl($returnUrl); }
/** * @param string|null $backToEshopUrl * @param array $params * * @throws Nette\Application\UI\InvalidLinkException */ public function setBackToEshopUrl($backToEshopUrl = NULL, $params = []) { if ($backToEshopUrl !== NULL && preg_match('~^([\\w:]+):(\\w*+)(#.*)?()\\z~', $backToEshopUrl)) { $backToEshopUrl = $this->linkGenerator->link($backToEshopUrl, $params); } parent::setBackToEshopUrl($backToEshopUrl); }
public function onSuccessCommentRemoval(Comment $comment, $id) { /** @var \Users\User $user */ $user = $this->user->getIdentity(); $pageLink = $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $comment->getPageId()]); $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has REMOVED</b> the Comment [%s#] of Author [%s] on the <a href="%s">Page [%s#%s]</a>', $user->getId(), $user->getUsername(), $id, $comment->getAuthor(), $pageLink, $comment->getPageId(), $comment->getPageTitle()), 'page_comment_release', $user->getId()); }
public function create() { $grid = new Grid(); $grid->model = $this->clientFacade->createDSDoctrine(); $grid->addColumnText('name', 'Name')->setCustomRender(function ($item) { $href = $this->linkGenerator->link('Backend:Clients:update', array('id' => $item->id)); return "<a href ='" . $href . "'>" . $item->name . "</a>"; /* $el = Html::el('a'); // $item represents whole row. So you can get here any filed you want. $el->setText($item->name); $el->addAttributes(array('target'=>"_blank")); $el->href = $this->linkGenerator->link( 'Backend:Clients:product', // this is how you can generate any link MODULE_NAME:PRESENTER_NAME:ACTION_NAME array( // here is a place for path parameters. FE: here you are expecting /admin/<presenter>/<action>[/<id>] // id is a parameter we can set here. FYI [/<id>] means that id is not required parameter, it can be NULL. 'id' => $item->id ) ); return $el;*/ })->setSortable()->setFilterNumber(); $grid->addColumnText('product', 'Product')->setCustomRender(function ($item) { return $item->product->name; })->setSortable()->setFilterText()->setSuggestion(); $grid->addColumnText('address', 'Address')->setSortable()->setFilterText()->setSuggestion(); $grid->addActionHref('update', 'Update')->setIcon('pencil'); $grid->addActionEvent('delete', 'Delete', function ($item) { $this->clientFacade->delete($item); })->setIcon('trash-o')->setConfirm(function ($item) { return "Are you sure you want to delete {$item->name}?"; }); return $grid; }
protected function inlineWikiLink($Excerpt) { if (preg_match('/^\\[\\[([^]|]+)(?:\\|([^]]+))?\\]\\]/', $Excerpt['text'], $m)) { $page = explode('#', @$m[2] ?: $m[1], 2); $url = $this->linkGenerator->link('Wiki:', ['path' => str_replace(' ', '-', $page[0])]); if (isset($page[1])) { $url .= '#' . $page[1]; } return ['extent' => strlen($m[0]), 'element' => ['name' => 'a', 'handler' => 'line', 'text' => $m[1], 'attributes' => ['href' => $url]]]; } }
/** * Create link to actual handler endpoint * * @param array $params * * @return string * @throws \Nette\Application\UI\InvalidLinkException it handler doesn't have linkgenerator or endpoint */ public function createLink($params) { if (!$this->linkGenerator) { throw new InvalidStateException("You have setupLinkGenerator for this handler if you want to generate link in this handler"); } if (!$this->endpoint) { throw new InvalidStateException("You have setEndpoint() for this handler if you want to generate link in this handler"); } $params = array_merge(['version' => $this->endpoint->getVersion(), 'package' => $this->endpoint->getPackage(), 'apiAction' => $this->endpoint->getApiAction()], $params); return $this->linkGenerator->link('Api:Api:default', $params); }
/** * @param array $parameters * @param $redirectToAction - etc. 'Front:Sign:in' * @param string $method * @param int $userId * @param string $userRole * @param bool $ignoreRedirectUrlParameters * @throws \Nette\Application\UI\InvalidLinkException */ public function checkRedirectTo($parameters = array(), $redirectToAction, $method = 'GET', $userId = NULL, $userRole = self::DEFAULT_USER_ROLE, $ignoreRedirectUrlParameters = TRUE) { $response = $this->sendRequest($parameters, $method, $userId, $userRole); $this->assertTrue($response instanceof \Nette\Application\Responses\RedirectResponse); if ($ignoreRedirectUrlParameters) { $responseUrl = $response->getUrl(); $endPos = strrpos($responseUrl, '?'); $responseUrlWithoutParameters = Strings::substring($responseUrl, 0, $endPos === FALSE ? NULL : $endPos); $this->assertSame($this->linkGenerator->link($redirectToAction), $responseUrlWithoutParameters); } else { $this->assertSame($this->linkGenerator->link($redirectToAction), $response->getUrl()); } }
protected function getUrl($presenterString) { if (preg_match('~^([\\w:]+):(\\w*+)(#[a-zA-Z][\\w:.-]*)?(?:(?:,[ ]+\\{)([a-zA-Z0-9=>\\{\\},.:\\-_ \'"]+)(?:\\}))?()\\z~', $presenterString, $m)) { list(, $presenter, $action, $frag, $rawParameters) = $m; if (strlen($frag) > 0 && $frag[0] != '#') { $rawParameters = $frag; $frag = ''; } try { $parameters = Nette\Utils\Json::decode('{' . $rawParameters . '}', Nette\Utils\Json::FORCE_ARRAY); } catch (Nette\Utils\JsonException $e) { $parameters = []; } if (is_null($parameters)) { $parameters = []; } try { return $this->linkGenerator->link((empty($presenter) ? '' : $presenter . ':') . $action . $frag, $parameters); } catch (Nette\Application\UI\InvalidLinkException $e) { return '#' . (empty($presenter) ? '' : $presenter . ':') . $action . $frag . (count($parameters) > 0 ? '?' : '') . join('&', $parameters); } } return FALSE; }
/** * Create link to specified api endpoint * * @param EndpointIdentifier $endpoint * @param array $params * * @return string */ public function link(EndpointIdentifier $endpoint, $params = []) { $params = array_merge(['version' => $endpoint->getVersion(), 'package' => $endpoint->getPackage(), 'apiAction' => $endpoint->getApiAction()], $params); return $this->linkGenerator->link('Api:Api:default', $params); }
/** * {@inheritdoc} */ public function link($destination, array $params = []) { return $this->linkGenerator->link($destination, $params); }
public function getNotificationMessage(Listing $newListing, User $sender) { $period = TimeUtils::getMonthName($newListing->month) . ' ' . $newListing->year; $m = new SentMessage($this->constructSubject($sender->username, $period), $this->constructMessage($sender->username, $newListing->getUser()->username, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $newListing->getId()])), $sender); return $m; }
/** * @param $destination * @param array $params */ public function setAsClickable($destination, array $params = []) { $this->link = $this->linkGenerator->link($destination, $params); $this->isClickable = true; }
/** * @param string $formatString * @param Page $page * @return string * @throws \Nette\Application\UI\InvalidLinkException */ private function createLogMessage($formatString, Page $page) { return sprintf($formatString, $this->user->getId(), $this->user->getUsername(), $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $page->getId()]), $page->isDraft() ? ' draft' : '', $page->getId(), $page->getTitle()); }
/** * Generates URL from the given parameters. * @param string $name * @param array $parameters * @param boolean $absolute * @return string */ public function generate($name, array $parameters, $absolute = true) { return $this->linkGenerator->link($name, $parameters); }
public function getNotificationMessage(Listing $listing, $senderName, $recipientName) { $period = TimeUtils::getMonthName($listing->month) . ' ' . $listing->year; $m = new Message($this->constructSubject($senderName, $period), $this->constructMessage($senderName, $recipientName, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $listing->listingID])), 0); return $m; }