diff --git a/src/Application/LinkGenerator.php b/src/Application/DefaultLinkGenerator.php similarity index 97% rename from src/Application/LinkGenerator.php rename to src/Application/DefaultLinkGenerator.php index 60d779dcf..13a97c980 100644 --- a/src/Application/LinkGenerator.php +++ b/src/Application/DefaultLinkGenerator.php @@ -17,7 +17,7 @@ /** * Link generator. */ -final class LinkGenerator implements ILinkGenerator +final class DefaultLinkGenerator implements ILinkGenerator { use Nette\SmartObject; diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index d658cd63d..03a638ec5 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -104,7 +104,7 @@ public function loadConfiguration() $builder->addDefinition($this->prefix('linkGenerator')) ->setType(Nette\Application\ILinkGenerator::class) - ->setFactory(Nette\Application\LinkGenerator::class, [ + ->setFactory(Nette\Application\DefaultLinkGenerator::class, [ 1 => new Definitions\Statement([new Definitions\Statement('@Nette\Http\IRequest::getUrl'), 'withoutUserInfo']), ]); diff --git a/src/compatibility-intf.php b/src/compatibility-intf.php index fff947040..d4b9d1c8e 100644 --- a/src/compatibility-intf.php +++ b/src/compatibility-intf.php @@ -24,6 +24,15 @@ class_alias(\Nette\Routing\Router::class, IRouter::class); class_alias(Response::class, IResponse::class); } +if (false) { + /** @deprecated use ILinkGenerator */ + interface LinkGenerator + { + } +} elseif (!interface_exists(LinkGenerator::class)) { + class_alias(\Nette\Application\ILinkGenerator::class, LinkGenerator::class); +} + namespace Nette\Application\UI; if (false) { diff --git a/tests/Bridges.DI/ApplicationExtension.basic.phpt b/tests/Bridges.DI/ApplicationExtension.basic.phpt index 7f31806fc..cfda062b2 100644 --- a/tests/Bridges.DI/ApplicationExtension.basic.phpt +++ b/tests/Bridges.DI/ApplicationExtension.basic.phpt @@ -25,5 +25,5 @@ test('', function () { $container = new Container1; Assert::type(Nette\Application\Application::class, $container->getService('application')); Assert::type(Nette\Application\PresenterFactory::class, $container->getService('nette.presenterFactory')); - Assert::type(Nette\Application\LinkGenerator::class, $container->getService('application.linkGenerator')); + Assert::type(Nette\Application\DefaultLinkGenerator::class, $container->getService('application.linkGenerator')); }); diff --git a/tests/Routers/LinkGenerator.phpt b/tests/Routers/LinkGenerator.phpt index 6761e67a9..b99313eec 100644 --- a/tests/Routers/LinkGenerator.phpt +++ b/tests/Routers/LinkGenerator.phpt @@ -39,7 +39,7 @@ namespace ModuleModule { namespace { - use Nette\Application\LinkGenerator; + use Nette\Application\DefaultLinkGenerator; use Nette\Application\PresenterFactory; use Nette\Application\Routers; use Nette\Http; @@ -50,7 +50,7 @@ namespace { test('', function () use ($pf) { - $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/'), $pf); + $generator = new DefaultLinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/'), $pf); Assert::same('http://nette.org/en/?action=default&presenter=Homepage', $generator->link('Homepage:default')); Assert::same('http://nette.org/en/?action=default&presenter=Module%3AMy', $generator->link('Module:My:default')); Assert::same('http://nette.org/en/?presenter=Module%3AMy', $generator->link('Module:My:')); @@ -63,25 +63,25 @@ namespace { Assert::exception(function () use ($pf) { - $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/'), $pf); + $generator = new DefaultLinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/'), $pf); $generator->link('default'); }, Nette\Application\UI\InvalidLinkException::class, "Invalid link destination 'default'."); Assert::exception(function () use ($pf) { - $generator = new LinkGenerator(new Routers\Route('/', 'Product:'), new Http\UrlScript('http://nette.org/en/'), $pf); + $generator = new DefaultLinkGenerator(new Routers\Route('/', 'Product:'), new Http\UrlScript('http://nette.org/en/'), $pf); $generator->link('Homepage:default', ['id' => 10]); }, Nette\Application\UI\InvalidLinkException::class, 'No route for Homepage:default(id=10)'); Assert::exception(function () use ($pf) { - $generator = new LinkGenerator(new Routers\Route('/', 'Homepage:'), new Http\UrlScript('http://nette.org/en/'), $pf); + $generator = new DefaultLinkGenerator(new Routers\Route('/', 'Homepage:'), new Http\UrlScript('http://nette.org/en/'), $pf); $generator->link('Homepage:missing', [10]); }, Nette\Application\UI\InvalidLinkException::class, "Unable to pass parameters to action 'Homepage:missing', missing corresponding method."); test('', function () { - $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/')); + $generator = new DefaultLinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/')); Assert::same('http://nette.org/en/?action=default&presenter=Homepage', $generator->link('Homepage:default')); Assert::same('http://nette.org/en/?action=default&presenter=Module%3AMy', $generator->link('Module:My:default')); Assert::same('http://nette.org/en/?presenter=Module%3AMy', $generator->link('Module:My:')); @@ -94,7 +94,7 @@ namespace { test('', function () { - $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/')); + $generator = new DefaultLinkGenerator(new Routers\SimpleRouter, new Http\UrlScript('http://nette.org/en/')); $generator2 = $generator->withReferenceUrl('http://nette.org/cs/'); Assert::same('http://nette.org/en/?action=default&presenter=Homepage', $generator->link('Homepage:default')); Assert::same('http://nette.org/cs/?action=default&presenter=Homepage', $generator2->link('Homepage:default'));