stephpy / timeline-bundle

Symfony2 bundle to make timeline
192 stars 57 forks source link

preventing exceptions in rendering a timeline element #166

Closed smarques closed 10 years ago

smarques commented 10 years ago

Hi, I have a complex range of timeline elements with different data structures so its possible that sooner or later something breaks and I get an exception that blows up the entire timeline if it gets raised within the tig call 'timeline_render'. What would be the best way to achieve the following behaviour from timeline render (de facto its a try and catch):

Thanks so much for any help sergio

stephpy commented 10 years ago

Hi,

timeline_render behavior is simple. You have documentation here

Your verb file looks like to something like that:

{{ timeline_component_render(timeline,'subject') }} eat with {{ timeline_component_render(timeline,'directComplement') }}

Here, you see the usage of timeline_component_render. By default, it call the __toString method of object or use string. You are able to uses components to customize the render of yours object/verbs.

Where would you have an exception ?

If it's on the verb file, you should use twig asserters because timeline bundle cannot do anything.

{% if action.hasComponent('directComplement') %}
.........
{% endif %}

If it's because integrity of complements is not sure, you should look at DataHydrator filter and its option to remove unloaded components

I hope i answered to your questions.

smarques commented 10 years ago

Thank you for your reply. Yes its related to the integrity of components. Will look at the dataHydrator filter. Thanks for pointing me to the solution :) :+1:

stephpy commented 10 years ago

You're welcome.