-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preparations for symfony 4.0 #286
Conversation
@dbu can we remove 5.3 support? |
Command/LoadFixtureCommand.php
Outdated
@@ -136,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output) | |||
if ($dirOrFile) { | |||
$paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile); | |||
} else { | |||
/** @var $kernel KernelInterface */ | |||
/** @var $kernel \Symfony\Component\HttpKernel\KernelInterface */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep the use statement for this. we are using the kernel in this class so the use statement gives a hint about that.
@@ -71,6 +71,7 @@ public function load(array $configs, ContainerBuilder $container) | |||
|
|||
if (!empty($config['manager_registry_service_id'])) { | |||
$container->setAlias('doctrine_phpcr', new Alias($config['manager_registry_service_id'])); | |||
$container->getDefinition($config['manager_registry_service_id'])->setPublic(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we dynamically set this service to public? i think the manager registry service should be always public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from Symfony 3.3 on all services are private by default, that is the major reason and work for the mirgration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and i miss some more, all that i do public in: symfony-cmf/Testing#145 really hard to find :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're setting a userland service to public that the application developer might have declared private for a reason. I don't think a bundle should do that.
Instead, since you're setting an alias to that service ID anyway, always wire and use the alias for internal logic. You could even set that alias to public if you need to access it from the container directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that, but setting it hard to public feels like having the behavior the user used to have before Symfony 3.3, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A now i see that i changed the wrong line ... thanks will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, the alias should be public, but not the other service. i tried to find what this even is for, and found no single bit of documentation neither in the doctrine phpcr bundle config reference, nor in the orm bundle doc...
i think what you need to make public however is <service id="doctrine_phpcr" class="%doctrine_phpcr.class%">
in phpcr.xml. (i will do a PR to eliminate the class parameters for master (upcoming version 2) like we do everywhere else)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that, but setting it hard to public feels like having the behavior the user used to have before Symfony 3.3, or?
Private services have existed ever since. You don't know whether a service is private due to the changed defaults in Symfony 4 or because it was set to private explicitly. It's not your responsibility to create BC for other people's services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some nitpicks, otherwise looks good to me, thanks!
ManagerRegistry.php
Outdated
$defaultEntityManager, | ||
$proxyInterfaceName | ||
) { | ||
$this->container = $container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we not also declare the field for this?
ManagerRegistry.php
Outdated
array $connections, | ||
array $entityManagers, | ||
$defaultConnection, | ||
$defaultEntityManager, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should append Name to this and the $defaultConnection and then we can remove the docblock as it will not provide any additional information.
Resources/config/phpcr.xml
Outdated
<argument>%doctrine_phpcr.sessions%</argument> | ||
<argument>%doctrine_phpcr.odm.document_managers%</argument> | ||
<argument>%doctrine_phpcr.default_session%</argument> | ||
<argument>%doctrine_phpcr.odm.default_document_manager%</argument> | ||
<argument>%doctrine_phpcr.proxy.class%</argument> | ||
<call method="setContainer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, dunno why we did it like this and not always inject the container in the constructor... thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to go on symfony 4.0 i think also needed for PSR-11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I wrote in #285, what about using a ServiceLocator (introduced in Symfony 3.3)? It may be harder to implement as you have to support both setContainer and the ServiceLocator but it looks more Symfonish!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But how to test it? I can inject a defined set of services the locator could serve right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep it simple here to keep working as it did before. service locator can be tried as a separate pull request once this is merged. ok?
@@ -71,6 +71,7 @@ public function load(array $configs, ContainerBuilder $container) | |||
|
|||
if (!empty($config['manager_registry_service_id'])) { | |||
$container->setAlias('doctrine_phpcr', new Alias($config['manager_registry_service_id'])); | |||
$container->getDefinition($config['manager_registry_service_id'])->setPublic(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're setting a userland service to public that the application developer might have declared private for a reason. I don't think a bundle should do that.
Instead, since you're setting an alias to that service ID anyway, always wire and use the alias for internal logic. You could even set that alias to public if you need to access it from the container directly.
ManagerRegistry.php
Outdated
use Symfony\Bridge\Doctrine\ManagerRegistry as BaseManagerRegistry; | ||
use Doctrine\ODM\PHPCR\PHPCRException; | ||
|
||
class ManagerRegistry extends BaseManagerRegistry | ||
{ | ||
/** | ||
* @var ContainerInterface | ||
*/ | ||
private $container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ManagerRegistry
class of DoctrineBridge already defines this field!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Thanks
if you rebase on master, the styleci error should be gone. i fixed it on master. i am also doing some cleanup (like dropping obsolete php and symfony versions) in #287. hopefully we can quickly wrap up that cleanup and merge, then you can rebase here and get rid of some more things. |
806d295
to
3d7bc69
Compare
@dbu heading to https://github.com/symfony-cmf/testing/blob/0749a2791a7538a96743e8417a93300c71b2694c/src/HttpKernel/ServiceVisibilityCompilerPass.php#L27 and i think i still miss some aliases/services which make problems, can you give me a hint where to finde them? |
i will give it a try tonight |
@dbu can we have both? A service and an alias with id |
the alias is only created in a special case when the user specifies their own registry in the config. the alias must be public (if that is not by default). but the doctrine_phpcr service we define ourselves must be public - its defined in one of the services xml files. |
So, i need to get this one too and than rebase on a new master. |
5c9dd7b
to
ca8b1e9
Compare
3c69900
to
563c982
Compare
18a90da
to
be381b0
Compare
@dbu why? i would like to rebase on master now and squash |
i did not actively close this PR, but i deleted my branch, and this goes against my branch and not master... i think github then automatically closes the PR. can you recreate this as a PR against master? |
a1f4562
to
5e6ac24
Compare
.travis.yml
Outdated
@@ -1,6 +1,8 @@ | |||
language: php | |||
|
|||
php: | |||
- 5.6 | |||
- 7.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those where dropped on purpose, lets not re-add them
.travis.yml
Outdated
env: SYMFONY_VERSION=3.3.* | ||
- php: hhvm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the php requirement 7.1 is not compatible with hhvm according to composer
composer.json
Outdated
@@ -29,7 +29,7 @@ | |||
"phpunit/php-code-coverage": "~2.2", | |||
"symfony/form": "~2.3|~3.0", | |||
"doctrine/phpcr-odm": "^1.3.0-rc4", | |||
"symfony-cmf/testing": "^2.1@dev", | |||
"symfony-cmf/testing": "^1.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this on purpose?
@dbu the changes had been some rebase conflict waste only. Should be ok now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some questions about the registry, otherwise this looks fine to me!
// and then also, the constructor should type-hint Psr\Container\ContainerInterface | ||
$this->setContainer($container); | ||
} else { | ||
$this->container = $container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the new version still have the container property? but not accept the container in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is adopted from the orm bundle. In on case there is the property in the abstract class in the other one it lives in the trait.
ManagerRegistry.php
Outdated
use Symfony\Bridge\Doctrine\ManagerRegistry as BaseManagerRegistry; | ||
use Doctrine\ODM\PHPCR\PHPCRException; | ||
|
||
class ManagerRegistry extends BaseManagerRegistry | ||
{ | ||
public function __construct( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is technically a BC break, but we are moving to version 2 so thats ok.
i think we should mark this class as @internal
, users should just use it in the service but not as custom code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the class final and marked it as internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, making it final does not work out. reverted that bit, only left the comment
$connectionAliasName = sprintf('doctrine_phpcr%s.jackalope_doctrine_dbal.%s_connection', $serviceNamePrefix, $session['name']); | ||
$container->setAlias($connectionAliasName, $connectionService); | ||
$container->setAlias($connectionAliasName, $connectionAlias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so much more understandable, nice cleanup!
7a2dd43
to
7a4a234
Compare
7a4a234
to
bd1267c
Compare
So lets merge this? |
bd1267c
to
91887b9
Compare
ah you merged the testing component thing. great, i just squashed the commits, if its green lets merge. |
.travis.yml
Outdated
@@ -18,6 +18,9 @@ matrix: | |||
- php: 7.1 | |||
env: SYMFONY_VERSION=3.3.* | |||
fast_finish: true | |||
allow_failures: | |||
- php: 7.1 | |||
env: SYMFONY_VERSION=^3.4@dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not in the matrix above, so its never run. should we add it?
@dbu i didn't merge testing, i will do when this is merged and use |
after rebase fixes re-add missing symfony version Support Symfony 4.0
c061c68
to
795a3e6
Compare
i was referring to composer.json referenced a branch of symfony-cmf/testing for a while, and now points to 2.1 again. i assumed that means you merged whatever was needed for the testing to have this merged. thanks a lot for your efforts here! |
fix #285
fix #281