stephpy/timeline-bundle

Error when getting data of component

Closed this issue · 5 comments

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.

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

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

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

Thanks @tuxone ;)

I close the issue. :)