Skip to content

Commit b901a27

Browse files
committed
LinkGenerator: extract interface
1 parent 7f29e32 commit b901a27

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/Application/ILinkGenerator.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Application;
11+
12+
13+
/**
14+
* Link generator.
15+
*/
16+
interface ILinkGenerator
17+
{
18+
/**
19+
* Generates URL to presenter.
20+
* @param string $dest in format "[[[module:]presenter:]action] [#fragment]"
21+
* @throws UI\InvalidLinkException
22+
*/
23+
public function link(string $dest, array $params = []): string;
24+
25+
public function withReferenceUrl(string $url): self;
26+
}

src/Application/LinkGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Link generator.
1919
*/
20-
final class LinkGenerator
20+
final class LinkGenerator implements ILinkGenerator
2121
{
2222
use Nette\SmartObject;
2323

src/Bridges/ApplicationDI/ApplicationExtension.php

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function loadConfiguration()
103103
}
104104

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

0 commit comments

Comments
 (0)