Skip to content

Commit

Permalink
No double brackets parsing by default
Browse files Browse the repository at this point in the history
  • Loading branch information
kapxapot committed Feb 24, 2020
1 parent 37a7dec commit 2b2fb2b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 44 deletions.
29 changes: 27 additions & 2 deletions src/Config/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
use Plasticode\IO\Image;
use Plasticode\Models\MenuItem;
use Plasticode\Models\Role;
use Plasticode\Parsing\LinkMappers\NewsLinkMapper;
use Plasticode\Parsing\LinkMappers\PageLinkMapper;
use Plasticode\Parsing\LinkMappers\TagLinkMapper;
use Plasticode\Parsing\LinkMapperSource;
use Plasticode\Parsing\Parsers\BB\BBParser;
use Plasticode\Parsing\Parsers\BB\Container\BBContainerParser;
use Plasticode\Parsing\Parsers\BB\Container\BBSequencer;
Expand Down Expand Up @@ -383,15 +387,36 @@ function ($tPath) {
);
},

'doubleBracketsConfig' => function (ContainerInterface $container) {
return new DoubleBracketsConfig(
'tagLinkMapper' => function (ContainerInterface $container) {
return new TagLinkMapper(
$container->renderer,
$container->linker
);
},

'pageLinkMapper' => function (ContainerInterface $container) {
return new PageLinkMapper(
$container->pageRepository,
$container->tagRepository,
$container->renderer,
$container->linker,
$container->tagLinkMapper
);
},

'newsLinkMapper' => function (ContainerInterface $container) {
return new NewsLinkMapper(
$container->renderer,
$container->linker
);
},

'doubleBracketsConfig' => function (ContainerInterface $container) {
// no double brackets link mappers by default
// add them!
return new LinkMapperSource();
},

'doubleBracketsParser' => function (ContainerInterface $container) {
return new DoubleBracketsParser(
$container->doubleBracketsConfig
Expand Down
38 changes: 0 additions & 38 deletions src/Config/Parsing/DoubleBracketsConfig.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Parsing/LinkMapperSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Plasticode\Parsing\Interfaces\LinkMapperInterface;
use Plasticode\Parsing\Interfaces\LinkMapperSourceInterface;

abstract class LinkMapperSource implements LinkMapperSourceInterface
class LinkMapperSource implements LinkMapperSourceInterface
{
/** @var LinkMapperInterface|null */
private $defaultMapper;
Expand Down
18 changes: 15 additions & 3 deletions tests/Factories/LinkMapperSourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Plasticode\Tests\Factories;

use Plasticode\Config\Parsing\DoubleBracketsConfig;
use Plasticode\Core\Interfaces\RendererInterface;
use Plasticode\Parsing\LinkMappers\NewsLinkMapper;
use Plasticode\Parsing\LinkMappers\PageLinkMapper;
use Plasticode\Parsing\LinkMappers\TagLinkMapper;
use Plasticode\Parsing\LinkMapperSource;
use Plasticode\Tests\Mocks\GenericLinkMapperMock;
use Plasticode\Tests\Mocks\LinkerMock;
Expand All @@ -16,13 +18,23 @@ public static function make(RendererInterface $renderer) : LinkMapperSource
{
$linker = new LinkerMock();

$config = new DoubleBracketsConfig(
$tagLinkMapper = new TagLinkMapper($renderer, $linker);

$pageLinkMapper = new PageLinkMapper(
new PageRepositoryMock(),
new TagRepositoryMock(),
$renderer,
$linker
$linker,
$tagLinkMapper
);

$config = new LinkMapperSource();

$config->setDefaultMapper($pageLinkMapper);

$config->registerEntityMapper(new NewsLinkMapper($renderer, $linker));
$config->registerEntityMapper($tagLinkMapper);

$config->setGenericMapper(new GenericLinkMapperMock());

return $config;
Expand Down

0 comments on commit 2b2fb2b

Please sign in to comment.