diff --git a/.docs/README.md b/.docs/README.md index f605cbe..41b7231 100644 --- a/.docs/README.md +++ b/.docs/README.md @@ -2,7 +2,6 @@ ## Content -- [LinkGenerator (LinkGeneratorExtesion)](#link-generator) - [UI](#ui) - [Presenter](#presenter) - [StructuredTemplates](#structured-templates) @@ -16,16 +15,6 @@ - [FlyResponse - send file/buffer on-the-fly](#flyresponse) - [XmlResponse](#xmlresponse) -## Link Generator - -A tiny extension which provides cacheable LinkGenerator. LinkGenerator is an external service for creating -URL addresses / links out of presenter scope, e.g. in mail templates. - -```yaml -extensions: - link: Contributte\Application\DI\LinkGeneratorExtension -``` - ## UI ### Presenter diff --git a/README.md b/README.md index 7409865..dd5742d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ composer require contributte/application ## Overview -- [LinkGenerator (LinkGeneratorExtension)](https://github.com/contributte/application/blob/master/.docs/README.md#link-generator) - [UI](https://github.com/contributte/application/blob/master/.docs/README.md#ui) - [Presenter](https://github.com/contributte/application/blob/master/.docs/README.md#presenter) - [StructuredTemplates](https://github.com/contributte/application/blob/master/.docs/README.md#structured-templates) diff --git a/composer.json b/composer.json index 5cc2dfe..6fab0bc 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,10 @@ "require-dev": { "ninjify/qa": "^0.8.0", "ninjify/nunjuck": "^0.2.0", - "nette/di": "~2.4.11", "nette/http": "~2.4.8", "psr/http-message": "~1.0.1", "tracy/tracy": "~2.5.3" }, - "suggest": { - "nette/di": "to use LinkGeneratorExtesion[CompilerExtension]" - }, "autoload": { "psr-4": { "Contributte\\Application\\": "src" diff --git a/src/DI/LinkGeneratorExtension.php b/src/DI/LinkGeneratorExtension.php deleted file mode 100644 index e9f1153..0000000 --- a/src/DI/LinkGeneratorExtension.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class LinkGeneratorExtension extends CompilerExtension -{ - - public function loadConfiguration(): void - { - $builder = $this->getContainerBuilder(); - - $builder->addDefinition($this->prefix('generator')) - ->setClass(MemoryLinkGenerator::class, [ - 1 => new Statement('@Nette\Http\IRequest::getUrl'), - ]); - } - -} diff --git a/src/ILinkGenerator.php b/src/ILinkGenerator.php deleted file mode 100644 index 08b92b9..0000000 --- a/src/ILinkGenerator.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface ILinkGenerator -{ - - /** - * @param string $dest in format "[[[module:]presenter:]action] [#fragment]" - * @param mixed[] $params - * @return string - * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint - */ - public function link($dest, array $params = []); - -} diff --git a/src/LinkGenerator.php b/src/LinkGenerator.php deleted file mode 100644 index 33f4bf2..0000000 --- a/src/LinkGenerator.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -class LinkGenerator extends NetteLinkGenerator implements ILinkGenerator -{ - -} diff --git a/src/MemoryLinkGenerator.php b/src/MemoryLinkGenerator.php deleted file mode 100644 index b366ead..0000000 --- a/src/MemoryLinkGenerator.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -class MemoryLinkGenerator extends LinkGenerator -{ - - /** @var string[] */ - private $cache = []; - - /** - * @param string $dest - * @param mixed[] $params - * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - */ - public function link($dest, array $params = []): string - { - // Generates cache key - $cacheKey = md5(serialize([$dest, $params])); - - if (!isset($this->cache[$cacheKey])) { - // Forward to real link generator - $this->cache[$cacheKey] = parent::link($dest, $params); - } - - return $this->cache[$cacheKey]; - } - -} diff --git a/tests/cases/DI/LinkGeneratorExtension.phpt b/tests/cases/DI/LinkGeneratorExtension.phpt deleted file mode 100644 index 343bdd5..0000000 --- a/tests/cases/DI/LinkGeneratorExtension.phpt +++ /dev/null @@ -1,34 +0,0 @@ -load(function (Compiler $compiler): void { - $compiler->addExtension('link', new LinkGeneratorExtension()); - $compiler->addExtension('application', new ApplicationExtension()); - $compiler->addExtension('routing', new RoutingExtension()); - $compiler->addExtension('http', new HttpExtension()); - }, 1); - - /** @var Container $container */ - $container = new $class(); - - Assert::type(MemoryLinkGenerator::class, $container->getService('link.generator')); - Assert::type(MemoryLinkGenerator::class, $container->getByType(ILinkGenerator::class)); -});