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

Service creates as private #55

Open
glembus opened this issue Dec 24, 2018 · 5 comments
Open

Service creates as private #55

glembus opened this issue Dec 24, 2018 · 5 comments

Comments

@glembus
Copy link

glembus commented Dec 24, 2018

Hello,
A have received deprecation message The "neo4j.entity_manager" service is private, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.. As I understood when sets alias for default manager it sets with private true but default service creates as not private.
Message fires from Neo4jBundle::boot(). Here it is private.
Maybe I doing something wrong.

I have changed $container->setAlias('neo4j.entity_manager', 'neo4j.entity_manager.default')` to

$id = new Alias($container->normalizeId('neo4j.entity_manager.default'), true);
$container->setAlias('neo4j.entity_manager', $id);

that help to set Alias as not private. But debug still tell that service is private..

 php bin/console debug:container neo4j.entity_manager

 // This service is an alias for the service neo4j.entity_manager.default                                               

Information for Service "neo4j.entity_manager.default"
======================================================

 ---------------- ------------------------------------ 
  Option           Value                               
 ---------------- ------------------------------------ 
  Service ID       neo4j.entity_manager.default        
  Class            GraphAware\Neo4j\OGM\EntityManager  
  Tags             -                                   
  Public           no                                  
  Synthetic        no                                  
  Lazy             no                                  
  Shared           yes                                 
  Abstract         no                                  
  Autowired        no                                  
  Autoconfigured   no                                  
 ---------------- ------------------------------------ 

Maybe I'm doing something wrong? I just add it and all tests fired deprecations

@glembus glembus changed the title Service will create as private Service creates as private Dec 24, 2018
@glembus
Copy link
Author

glembus commented Dec 24, 2018

That helps me resolve deprecation firing
Neo4jExtension::handleEntityMangers line 140 I add $definition->setPublic(true);
But why that helps? In my case should be used ChildDefinition::class and it used but when creating alias were used properties from Definition::class ant service sets as public and private.

@Nyholm
Copy link
Collaborator

Nyholm commented Dec 25, 2018

That is correct. All services should be private my default.
That is symfony's best practice since 4.0.

Use dependency injection instead of using the container directly.

@Nyholm Nyholm closed this as completed Dec 25, 2018
@Nyholm
Copy link
Collaborator

Nyholm commented Dec 26, 2018

Oh I see. The bundle itself is using the container here: https://github.com/neo4j-contrib/neo4j-symfony/blob/master/Neo4jBundle.php

This is indeed an issue.

@glembus
Copy link
Author

glembus commented Dec 26, 2018

I'm not understand in what way service have changed his state on setAlias() but before this row service have internal properties setted

$private = false;
$public = true;

After setting alias for service it change state to

$private = true;
$public = true;

Maybe this can help. And maybe this bag not related to bundle.

@glembus
Copy link
Author

glembus commented May 23, 2019

I think maybe need change logic when was checks if manager is configured. Doctrine creates some parameter to resolve this. As temporary solution maybe do same thing? What you think about this?

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

No branches or pull requests

2 participants