Skip to content
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

Merged
merged 1 commit into from
Nov 8, 2017
Merged

Conversation

ElectricMaxxx
Copy link
Contributor

@ElectricMaxxx ElectricMaxxx commented Oct 28, 2017

fix #285
fix #281

@ElectricMaxxx
Copy link
Contributor Author

@dbu can we remove 5.3 support?

@@ -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 */
Copy link
Member

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);
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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 :-)

Copy link
Member

@derrabus derrabus Oct 30, 2017

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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)

Copy link
Member

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.

Copy link
Member

@dbu dbu left a 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!

$defaultEntityManager,
$proxyInterfaceName
) {
$this->container = $container;
Copy link
Member

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?

array $connections,
array $entityManagers,
$defaultConnection,
$defaultEntityManager,
Copy link
Member

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.

<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">
Copy link
Member

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!

Copy link
Contributor Author

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

Copy link
Contributor

@fbourigault fbourigault Oct 30, 2017

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!

Copy link
Contributor Author

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?

Copy link
Member

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);
Copy link
Member

@derrabus derrabus Oct 30, 2017

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.

use Symfony\Bridge\Doctrine\ManagerRegistry as BaseManagerRegistry;
use Doctrine\ODM\PHPCR\PHPCRException;

class ManagerRegistry extends BaseManagerRegistry
{
/**
* @var ContainerInterface
*/
private $container;
Copy link
Member

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks

@dbu
Copy link
Member

dbu commented Oct 31, 2017

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.

@ElectricMaxxx
Copy link
Contributor Author

@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?

@dbu
Copy link
Member

dbu commented Oct 31, 2017

i will give it a try tonight

@ElectricMaxxx
Copy link
Contributor Author

@dbu can we have both? A service and an alias with id doctrine_phpcr? I still have failing tests on cmf cause a private service with that name is used.

@dbu
Copy link
Member

dbu commented Nov 2, 2017

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.

@ElectricMaxxx
Copy link
Contributor Author

So, i need to get this one too and than rebase on a new master.

@ElectricMaxxx ElectricMaxxx changed the base branch from master to drop-class-parameters November 3, 2017 05:23
@dbu dbu closed this Nov 6, 2017
@ElectricMaxxx
Copy link
Contributor Author

@dbu why? i would like to rebase on master now and squash

@dbu
Copy link
Member

dbu commented Nov 6, 2017

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?

@ElectricMaxxx ElectricMaxxx changed the base branch from drop-class-parameters to master November 6, 2017 10:19
@ElectricMaxxx ElectricMaxxx reopened this Nov 6, 2017
.travis.yml Outdated
@@ -1,6 +1,8 @@
language: php

php:
- 5.6
- 7.0
Copy link
Member

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
Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this on purpose?

@ElectricMaxxx
Copy link
Contributor Author

@dbu the changes had been some rebase conflict waste only. Should be ok now.

Copy link
Member

@dbu dbu left a 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;
Copy link
Member

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?

Copy link
Contributor Author

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.

use Symfony\Bridge\Doctrine\ManagerRegistry as BaseManagerRegistry;
use Doctrine\ODM\PHPCR\PHPCRException;

class ManagerRegistry extends BaseManagerRegistry
{
public function __construct(
Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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);
Copy link
Member

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!

@ElectricMaxxx
Copy link
Contributor Author

So lets merge this?

@dbu
Copy link
Member

dbu commented Nov 7, 2017

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
Copy link
Member

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?

@ElectricMaxxx
Copy link
Contributor Author

@dbu i didn't merge testing, i will do when this is merged and use ^2.0@dev there. and then i will merge content-bundle, and then ... :-)

after rebase fixes

re-add missing symfony version

Support Symfony 4.0
@ElectricMaxxx ElectricMaxxx merged commit 69848ee into master Nov 8, 2017
@ElectricMaxxx ElectricMaxxx deleted the prepare_for_symfony_4.0 branch November 8, 2017 04:53
@dbu
Copy link
Member

dbu commented Nov 8, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inject Container in constructor Prepare for bundle less Symfony App
4 participants