stephpy / timeline-bundle

Symfony2 bundle to make timeline
192 stars 57 forks source link

Error when getting data of component #186

Closed semiaLi closed 9 years ago

semiaLi commented 9 years ago

Hello, I have a problem which block me and prevent me to advance. In fact i want to get the component Data so i do this: {% set component = action.getComponent('complement') %} {% set post = component.data %} {% set user = action.getComponent('subject').data %} {% set createdAt = action.createdAt %}

the problem is that component.data sush as action.getComponent('subject').data return me null :( Can you help me . and to test , i put {{ component.id }} and it return the true Id value.

tuxone commented 9 years ago

Maybe you didn't set up DataHydrator, take a look at https://github.com/stephpy/timeline-bundle/blob/master/Resources/doc/filter.markdown#datahydrator

semiaLi commented 9 years ago

But i don't use a personal datahydrator, i think this one is used to regroup the queries to avoid X queries call by action

tuxone commented 9 years ago

Just add these lines to your configuration (adjust orm or odm based on your case)

spy_timeline:
    filters:
        data_hydrator:
            priority:             20
            service:              spy_timeline.filter.data_hydrator
            filter_unresolved:    true
            locators:
                - spy_timeline.filter.data_hydrator.locator.doctrine_orm

and the component data attribute won't be null anymore ;)

semiaLi commented 9 years ago

thank you , the problem was the method i use to create the action :) i put $subject = $actionManager->findOrCreateComponent($user); $component= $actionManager->findOrCreateComponent($model); $action = $actionManager->create($subject, 'LIKE', array('component' => $component)); but when i put this: ($user and $model are simple entities ) $action = $actionManager->create($user, 'LIKE', array('component' => $model)); it works :D

stephpy commented 9 years ago

Thanks @tuxone ;)

I close the issue. :)