Skip to content

Commit

Permalink
LinkGenerator: extract interface
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelJurasek committed Jan 14, 2021
1 parent 7f29e32 commit b901a27
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/Application/ILinkGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

namespace Nette\Application;


/**
* Link generator.
*/
interface ILinkGenerator
{
/**
* Generates URL to presenter.
* @param string $dest in format "[[[module:]presenter:]action] [#fragment]"
* @throws UI\InvalidLinkException
*/
public function link(string $dest, array $params = []): string;

public function withReferenceUrl(string $url): self;
}
2 changes: 1 addition & 1 deletion src/Application/LinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Link generator.
*/
final class LinkGenerator
final class LinkGenerator implements ILinkGenerator
{
use Nette\SmartObject;

Expand Down
1 change: 1 addition & 0 deletions src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function loadConfiguration()
}

$builder->addDefinition($this->prefix('linkGenerator'))
->setType(Nette\Application\ILinkGenerator::class)
->setFactory(Nette\Application\LinkGenerator::class, [
1 => new Definitions\Statement([new Definitions\Statement('@Nette\Http\IRequest::getUrl'), 'withoutUserInfo']),
]);
Expand Down

0 comments on commit b901a27

Please sign in to comment.