Skip to content

Commit c20d8a3

Browse files
authored
Merge pull request #39 from terox/symfony4
Symfony4 support
2 parents 2fdc67e + f56195a commit c20d8a3

4 files changed

Lines changed: 13 additions & 45 deletions

File tree

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ language: php
22
sudo: false
33

44
php:
5-
- 5.5
6-
- 5.6
7-
- 7.0
8-
- hhvm
5+
- 7.1
6+
- 7.2
97

108
cache:
119
directories:
1210
- $HOME/.composer/cache
1311

1412
matrix:
1513
fast_finish: true
16-
allow_failures:
17-
- php: hhvm
1814

1915
before_install:
2016
- composer selfupdate
@@ -31,9 +27,6 @@ install:
3127
- if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest; fi;
3228
- composer require ramsey/uuid
3329

34-
before_script:
35-
- echo "<?php if (PHP_VERSION_ID >= 50400) echo ',@php5.4';" > php_version_tags.php
36-
3730
script:
3831
- bin/phpspec run --format=pretty
3932
#- ./vendor/bin/phpunit --testdox

composer.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
"minimum-stability": "dev",
1212
"prefer-stable": true,
1313
"require": {
14-
"php": ">=5.5.3",
15-
"doctrine/common": "~2.2",
16-
"doctrine/orm": "~2.2",
17-
"symfony/polyfill-php70": "^1.3",
18-
"symfony/security": "^2.8|^3.0",
19-
"symfony/options-resolver": "^2.8|^3.0",
14+
"php": ">=7.1",
15+
"doctrine/orm": "^2.6",
16+
"symfony/security": "^3.3|^4.0",
17+
"symfony/options-resolver": "^3.0|^4.0",
2018
"ircmaxell/random-lib": "~1.0",
21-
"symfony/dependency-injection": "^2.7|^3.3",
22-
"symfony/config": "^2.7|^3.3"
19+
"symfony/dependency-injection": "^3.3|^4.0",
20+
"symfony/config": "^3.3|^4.0"
2321
},
2422
"suggest": {
2523
"ramsey/uuid": "To use the UUID generator you should require this package"

src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ class GeneratorListener
2828
*/
2929
private $registry;
3030

31-
/**
32-
* @var ContainerInterface
33-
*/
34-
private $container;
35-
3631
/**
3732
* Registry has been made nullable as injecting it causes circular references. Instead, the container is injected
3833
* via a setter, and the registry is fetched from there instead.
@@ -46,14 +41,6 @@ public function __construct(Reader $reader, Registry $registry = null)
4641
$this->registry = $registry;
4742
}
4843

49-
/**
50-
* @param ContainerInterface $container
51-
*/
52-
public function setContainer(ContainerInterface $container)
53-
{
54-
$this->container = $container;
55-
}
56-
5744
/**
5845
* @param LifecycleEventArgs $args
5946
*/
@@ -92,7 +79,7 @@ public function prePersist(LifecycleEventArgs $args)
9279
private function generateString($property, GeneratorAnnotation $annotation, $entity)
9380
{
9481
/** @var GeneratorInterface|ConfigurableGeneratorInterface $generator */
95-
$generator = $this->getRegistry()->get($annotation->generator);
82+
$generator = $this->registry->get($annotation->generator);
9683

9784
$generator->setLength($annotation->length);
9885

@@ -168,15 +155,4 @@ private function isMethod($class, $callback)
168155
{
169156
return method_exists($class, $callback) && is_callable([$class, $callback]);
170157
}
171-
172-
/**
173-
* @return Registry
174-
*/
175-
private function getRegistry()
176-
{
177-
if($this->registry){
178-
return $this->registry;
179-
}
180-
return $this->container->get('vivait_generator.registry');
181-
}
182158
}

src/Vivait/StringGeneratorBundle/Resources/config/services.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ services:
22
vivait_generator.generator.listener:
33
class: Vivait\StringGeneratorBundle\EventListener\GeneratorListener
44
public: false
5-
arguments: ["@annotation_reader"]
6-
calls:
7-
- [setContainer, ["@service_container"]]
5+
arguments:
6+
- "@annotation_reader"
7+
- "@vivait_generator.registry"
8+
89
tags:
910
- { name: doctrine.event_listener, event: prePersist }
1011

0 commit comments

Comments
 (0)