stephpy/timeline-bundle

[2.0] Impossible to create component from directComplement.

Closed this issue · 19 comments

I'm trying to create an action from two objects "building" (class: Ysu\Bundle\OfficeSpaceBundle\Building) and its associated "city" (class: Proxies__CG__\Ysu\Bundle\SiteBundle\Entity\City). I use the following line of code:

$action = $actionManager->create($building, 'building_added',  array('directComplement' => $city));

I get the error:

Impossible to create component from directComplement.

When I try to debug, I can see the component being created with:

$component = $this->findOrCreateComponent($component);

In the AbstractActionManager. When I dive into that method in the ActionManager class I can see that an object "component" is returned, however, back in the AbstractActionManager, the returned object is NULL. I can't figure out what''s going on. Any clues?

Hi,

I guess i found the issue. Sorry, i made an error on definition of uses :\

Can you confirm it fixes your issue ?

Thank you.

Thanks for the quick reply!

Unfortunately that does not fix it..

Is your city and building are already persisted ? (i guess you are on orm driver, that'sit ?)

Yes they are persisted. I get the building from its repository and get the city thru association ($building->getAddress()->getCity())

I added an explicit exception, update version of timelineBundle and give me exception throwed please.

To find a component, you have to give a model (Delft) and an identifier ()

Delft is the city name (which i'm guesing is returned by the city's __toString() method)

Weird, it would not. The model should be the class or a string.
If you installed this bundle via composer, can you go on:

vendor/stephpy/TimelineBundle/Spy/TimelineBundle/Driver/ORM/ActionManager.php

And add

        // line 143 after list ($modelResolved, $identifierResolved, $data) = ..........

        print "<pre>";
        var_dump($modelResolved, $identifierResolved);
        print "</pre>";
        exit('die');
string 'Ysu\Bundle\SiteBundle\Entity\City' (length=33)
string '' (length=0)
die

It's may an issue on doctrine metadatas. Dump $fields on line 232 please and then $identifier on line 239. (sorry about this way to debug ... it's really a weird issue)

Thanks so much for helping!

Fields:

array (size=1)
  0 => string 'id' (length=2)
die

Identifier

array (size=1)
  'id' => string '' (length=0)
die

weird ... try to make $city->getId();

It seems than:

$data = (string) $metadata->reflFields[$field]->getValue($model);

return null.

I added a new exception to easily find this kind of issues.

Hmm wait, i made a mistake, i fix it.

It's ok, update the timelineBundle, then retry. If you have exception, try to make on line 238:

var_dump($model->getId());
die();
Field "id" of model "Proxies\__CG__\Ysu\Bundle\SiteBundle\Entity\City" return an empty result, model has to be persisted.

var_dump($model->getId()); at line 238 returns:

int 4

That is the correct id for the building.. So weird!

Yes it is :s. It seems to be a doctrine issue.

I will fetch value via getter, one sec.

Update and retry, it should be ok :)

Reopen if it's not

Awesome! Thanks!

You're welcome :) Thanks for using this bundle and help us to fix potentials issues ;)