Skip to content

Commit

Permalink
Merge 571f093 into 1f04a53
Browse files Browse the repository at this point in the history
  • Loading branch information
vrestihnat committed Jan 31, 2021
2 parents 1f04a53 + 571f093 commit a04bdbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": {
"php": ">=7.1",
"kdyby/strict-objects": "^2.0",
"latte/latte": "^2.5.2 || ^3.0",
"latte/latte": "^2.5.2 <= 2.8.4",
"nette/caching": "^3.0",
"nette/di": "^3.0",
"nette/finder": "^2.5",
Expand Down
12 changes: 8 additions & 4 deletions src/DI/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Kdyby\Translation\Translator as KdybyTranslator;
use Latte\Engine as LatteEngine;
use Nette\Application\Application;
use Nette\Bridges\ApplicationLatte\LatteFactory;
use Nette\Bridges\ApplicationLatte\ILatteFactory;
use Nette\Configurator;
use Nette\DI\Compiler;
Expand All @@ -40,7 +41,6 @@
use Nette\Reflection\ClassType as ReflectionClassType;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nette\Utils\Callback;
use Nette\Utils\Finder;
use Nette\Utils\Validators;
use Symfony\Component\Translation\Extractor\ChainExtractor;
Expand Down Expand Up @@ -297,12 +297,16 @@ public function beforeCompile()
->addSetup('addFilter', ['translate', [$this->prefix('@helpers'), 'translateFilterAware']]);
};

$latteFactoryService = $builder->getByType(ILatteFactory::class);
$latteFactoryService = $builder->getByType(LatteFactory::class)?: $builder->getByType(ILatteFactory::class) ;
if (!$latteFactoryService || !self::isOfType($builder->getDefinition($latteFactoryService)->getClass(), LatteEngine::class)) {
$latteFactoryService = 'nette.latteFactory';
}

if ($builder->hasDefinition($latteFactoryService) && self::isOfType($builder->getDefinition($latteFactoryService)->getClass(), ILatteFactory::class)) {
if ($builder->hasDefinition($latteFactoryService)
&& (self::isOfType($builder->getDefinition($latteFactoryService)->getClass(), LatteFactory::class)
|| self::isOfType($builder->getDefinition($latteFactoryService)->getClass(), ILatteFactory::class))
)
{
$registerToLatte($builder->getDefinition($latteFactoryService));
}

Expand Down Expand Up @@ -372,7 +376,7 @@ public function beforeCompile()
return str_replace((DIRECTORY_SEPARATOR === '/') ? '\\' : '/', DIRECTORY_SEPARATOR, Helpers::expand($dir, $builder->parameters));
}, $config['dirs']);

$dirs = array_values(array_filter($config['dirs'], Callback::closure('is_dir')));
$dirs = array_values(array_filter($config['dirs'], \Closure::fromCallable('is_dir')));
if (count($dirs) > 0) {
foreach ($dirs as $dir) {
$builder->addDependency($dir);
Expand Down

0 comments on commit a04bdbd

Please sign in to comment.