Skip to content

Commit

Permalink
Translator is not required.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Jan 15, 2021
1 parent 0faf62b commit 564db4c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CmsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Baraja\Cms\Plugin\UserPlugin;
use Baraja\Cms\Proxy\Proxy;
use Baraja\Cms\Support\Support;
use Baraja\Cms\Translator\TranslatorFilter;
use Baraja\Cms\User\UserManager;
use Baraja\Cms\User\UserManagerAccessor;
use Baraja\Doctrine\ORM\DI\OrmAnnotationsExtension;
Expand Down
1 change: 1 addition & 0 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


use Baraja\AdminBar\BasicPanel;
use Baraja\Cms\Translator\TranslatorFilter;
use Baraja\Cms\User\UserManagerAccessor;
use Baraja\Doctrine\EntityManager;
use Baraja\DynamicConfiguration\Configuration;
Expand Down
16 changes: 16 additions & 0 deletions src/Translator/CmsDefaultTranslator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Baraja\Cms\Translator;


use Nette\Localization\Translator;

final class CmsDefaultTranslator implements Translator
{
public function translate($message, ...$parameters): string
{
return (string) $message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Baraja\Cms;
namespace Baraja\Cms\Translator;


use Latte\Runtime\FilterInfo;
Expand All @@ -13,9 +13,9 @@ final class TranslatorFilter
private Translator $translator;


public function __construct(Translator $translator)
public function __construct(?Translator $translator = null)
{
$this->translator = $translator;
$this->translator = $translator ?? new CmsDefaultTranslator;
}


Expand Down

0 comments on commit 564db4c

Please sign in to comment.