Skip to content

Commit

Permalink
Merge pull request #1 from vrestihnat/nette-3.1
Browse files Browse the repository at this point in the history
nette 3.1 compatibility
  • Loading branch information
vrestihnat committed Jan 29, 2021
2 parents 1f04a53 + f8b6169 commit d0ad702
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/DI/TranslationExtension.php
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 d0ad702

Please sign in to comment.