Skip to content

Commit 4351864

Browse files
authored
Merge pull request #1588 from XWB/doctrine-deprecation
Fix Doctrine deprecation notice in RegisterListenersService
2 parents cc9c801 + 194e983 commit 4351864

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

.travis.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ matrix:
2525
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-clover=coverage.clover"
2626

2727
# Install all SF components in the same major version, see https://github.com/dunglas/symfony-lock
28-
- php: 7.3
29-
env: SYMFONY_VERSION="^4"
28+
- php: 7.4
29+
env: DEPENDENCIES="symfony/flex" SYMFONY_VERSION="^3.4"
30+
- php: 7.4
31+
env: DEPENDENCIES="symfony/flex" SYMFONY_VERSION="^4.4"
3032

3133
before_install:
3234
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
3335

3436
install:
3537
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
3638
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
37-
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update dunglas/symfony-lock=$SYMFONY_VERSION; fi;
39+
- if [ "$DEPENDENCIES" != "" ]; then composer require --no-update ${DEPENDENCIES}; fi;
40+
- if [ "$SYMFONY_VERSION" != "" ]; then composer config extra.symfony.require ${SYMFONY_VERSION}; fi;
3841
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
3942
- mkdir /tmp/elasticsearch
4043
- wget -O - https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz | tar xz --directory=/tmp/elasticsearch --strip-components=1
@@ -44,7 +47,7 @@ install:
4447

4548
before_script:
4649
- phpenv config-add .travis/php.ini
47-
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
50+
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
4851

4952
script:
5053
- vendor/bin/phpunit ${PHPUNIT_FLAGS}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"require-dev": {
2525
"doctrine/orm": "^2.5",
2626
"doctrine/doctrine-bundle": "^1.6",
27+
"doctrine/persistence": "^1.3.3",
2728
"doctrine/phpcr-bundle": "^1.3|^2.0",
2829
"doctrine/phpcr-odm": "^1.4",
2930
"jackalope/jackalope-doctrine-dbal": "^1.2",

src/Doctrine/RegisterListenersService.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
<?php
2+
3+
/*
4+
* This file is part of the FOSElasticaBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
212
namespace FOS\ElasticaBundle\Doctrine;
313

4-
use Doctrine\Common\Persistence\ObjectManager;
514
use Doctrine\ODM\MongoDB\DocumentManager;
615
use Doctrine\ORM\EntityManagerInterface;
16+
use Doctrine\Persistence\ObjectManager;
717
use FOS\ElasticaBundle\Persister\Event\Events;
818
use FOS\ElasticaBundle\Persister\Event\PersistEvent;
919
use FOS\ElasticaBundle\Provider\PagerInterface;
@@ -46,10 +56,10 @@ public function register(ObjectManager $manager, PagerInterface $pager, array $o
4656
});
4757
}
4858

49-
if (false == $options['debug_logging'] && $manager instanceof EntityManagerInterface) {
59+
if (false === $options['debug_logging'] && $manager instanceof EntityManagerInterface) {
5060
$configuration = $manager->getConnection()->getConfiguration();
5161
$logger = $configuration->getSQLLogger();
52-
62+
5363
$this->addListener($pager, Events::PRE_FETCH_OBJECTS, function() use ($configuration) {
5464
$configuration->setSQLLogger(null);
5565
});
@@ -59,7 +69,7 @@ public function register(ObjectManager $manager, PagerInterface $pager, array $o
5969
});
6070
}
6171

62-
if (false == $options['debug_logging'] && $manager instanceof DocumentManager) {
72+
if (false === $options['debug_logging'] && $manager instanceof DocumentManager) {
6373
$configuration = $manager->getConnection()->getConfiguration();
6474
$logger = $configuration->getLoggerCallable();
6575

tests/Functional/ProfilerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
use Symfony\Component\HttpFoundation\Request;
2222
use Symfony\Component\HttpFoundation\Response;
2323
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
24+
use Twig\Loader\FilesystemLoader;
25+
use Twig\Environment;
26+
use Twig\RuntimeLoader\RuntimeLoaderInterface;
2427

2528
/**
2629
* @group functional
@@ -30,7 +33,7 @@ class ProfilerTest extends WebTestCase
3033
/** @var ElasticaLogger */
3134
private $logger;
3235

33-
/** @var \Twig_Environment */
36+
/** @var Environment */
3437
private $twig;
3538

3639
/** @var ElasticaDataCollector */
@@ -41,15 +44,15 @@ public function setUp()
4144
$this->logger = new ElasticaLogger($this->createMock(LoggerInterface::class), true);
4245
$this->collector = new ElasticaDataCollector($this->logger);
4346

44-
$twigLoaderFilesystem = new \Twig_Loader_Filesystem(__DIR__ . '/../../src/Resources/views/Collector');
47+
$twigLoaderFilesystem = new FilesystemLoader(__DIR__ . '/../../src/Resources/views/Collector');
4548
$twigLoaderFilesystem->addPath(__DIR__ . '/../../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler');
46-
$this->twig = new \Twig_Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);
49+
$this->twig = new Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);
4750

4851
$this->twig->addExtension(new CodeExtension('', '', ''));
4952
$this->twig->addExtension(new RoutingExtension($this->getMockBuilder(UrlGeneratorInterface::class)->getMock()));
5053
$this->twig->addExtension(new HttpKernelExtension($this->getMockBuilder(FragmentHandler::class)->disableOriginalConstructor()->getMock()));
5154

52-
$loader = $this->getMockBuilder(\Twig_RuntimeLoaderInterface::class)->getMock();
55+
$loader = $this->getMockBuilder(RuntimeLoaderInterface::class)->getMock();
5356
$loader->method('load')->willReturn($this->getMockBuilder(HttpKernelRuntime::class)->disableOriginalConstructor()->getMock());
5457
$this->twig->addRuntimeLoader($loader);
5558
}

0 commit comments

Comments
 (0)