stephpy/timeline-bundle

Demo not working, what am i doing wrong ?

Closed this issue · 5 comments

Hey,

I tryed to use the example with Redis driver,

To sum up i did (i did not paste all the code),

    $subject       = $actionManager->findOrCreateComponent('\User', 2);
    $action        = $actionManager->create($subject, 'control', array('directComplement' => 'the world'));

On the spread i send the event to the user 1,

Then I retrieve his wall :

    $subject         = $actionManager->findOrCreateComponent('\User', 1);

Finally I render his wall which only contains
" - "

When a do a var_dump I end up with :

bug

My config looks like :

spy_timeline:
    drivers:
        redis:
            client:           snc_redis.default # snc_redis.default
            pipeline:         true
            prefix:           vlr_timeline
            classes:
                action:           'Spy\Timeline\Model\Action'
                component:        'Spy\Timeline\Model\Component'
                action_component: 'Spy\Timeline\Model\ActionComponent'
    paginator: spy_timeline.paginator.knp

What did i do wrong ? I saw that redis must be in immediate delivery, but i can't find that option under snc_redis bundle

thanks

Hi, Delivery is on SpyTimelineBundle (default is immediate), it's not the issue here ;)

Spreads are OK too, your action looks like:

Subject => object Complement ('\User', 1)
complements =>
   directComplement => string "the world"

By this way, in your template you can do

{% for action in timeline %}
{{ action.subject.model }} {{ action.subject.identifier }}  - {{ action.verb }} - {{ action.getComponent('directComplement') }} 
{% endfor %}

This should returns:

\User 1 - control - the world

By default, {{ timeline_render }} render the data attribute of components which is the entity related (for \User:1) or the text.

I'm investigating to create a better example because it's a little bit confusing.

If you have any other question, feel free ;)

You can dump actionComponents from Model\Action, it'll be clearer.

If your \User:1 is a stored entity and you would like to load it when you are fetching the wall, look at DataHydrator section.

Ok thanks for the fast reply :-),

I still have one more question, then how to use the templates like in the example (to render different template according to the verb/i18n ? (the example you gave me in your message about rendering manually the timeline kind of confused me) ? Why the status is "pending" ? instead of delivered ?

so if i got it right, the next steps to create a complete wall system is :

  • hydrating the data from redis to doctrine for stored entities
  • add more spread, to define which verbs are delivered to who.
  • adding in the custom view the words that are not stored in redis like Subject is verb to/in/from.... ?

Thanks.

If output is "-" it's because twig engine fallback to default template, then define:

render:
        path:     'AcmeBundle:Timeline/verbs'
        i18n:
            fallback: en

And create directory `/path/to/acmebundle/Resources/views/Timeline/verbs/

You'll have to create one file per verb or it'll fallback to default template. In example, create control.html.twig and you'll be able to customize all actions which use this verb.
In the verb file, action variable is given with name timeline (it's a mistake, i'll replace it by action but timeline key will stay to not being BC BREAK)

If you use i18n, create control.en.html.twig, control.fr.html.twig.

For points:

  • hydrating the data from redis to doctrine for stored entities

Yes, you can add a locator if it's not a doctrine orm/odm entity.

  • add more spread, to define which verbs are delivered to who.

Right.

  • adding in the custom view the words that are not stored in redis like Subject is verb to/in/from.... ?

I'm not sure to understand this point.

I close this issue, if you have any other trouble, open a new one :)