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

Dependency injection is not applying for objects instances retrieved from fields of type "href" #1063

Closed
kanevbg opened this issue Nov 22, 2016 · 2 comments

Comments

@kanevbg
Copy link

kanevbg commented Nov 22, 2016

Steps to reproduce

Create two classes. In the second add field with name "myFirstObject", of type "href" and configure it to allow object of the other class.

Create with each class one object in the backed. Lets say object of the first class will get ID 1 and class 2 will get object with ID 2. On object #2 put a href to Object #1.

Create custom class "MyCustomFirstClass" which will extend the first class created from the PIMCore Backend.

Setup DI in /website/config/di.php for the custom class to replace the first one.
And check out what happens with that:

Code example

$o2 = \Pimcore\Model\Object\MySecondClass::getById(2);
$o1 = $o2->getMyFirstObject();

var_dump(get_class($o1));
var_dump(get_class(\Pimcore::getDiContainer()->make(\Pimcore\Model\Object\MyFirstClass::class)));


### Expected behavior 
"MyCustomFirstClass"
"MyCustomFirstClass"

### Actual behavior  
"MyFirstClass"
"MyCustomFirstClass"
  
@kanevbg
Copy link
Author

kanevbg commented Nov 22, 2016

Sorry, not actually bug. It was a caching issue, arghh...

@brusch brusch closed this as completed Nov 23, 2016
@brusch
Copy link
Member

brusch commented Nov 23, 2016

Yes, after you change the DI config you have to flush the cache :)

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