Adding cache tags#2
Conversation
|
Should also include cache contexts and max-age. Try using something like CacheableMetadata::createFromObject($view)->applyTo($build); |
|
That said, a lot here looks unported. the #type there doesn't do anyting because it has not been ported, so the only reason it does something at all is because the code additionally also hardcodes the #theme. I would recommend to build the initial render array like this: the argument parsing logic would have to change from a pre render callback to be done in the formatter. IMHO, that would be much easier to follow & understand. If necessary, the template could be kept as a wrapper template around the view. |
|
Alright, tried to implement this. Does this look right? Is the usage of _viewfield_get_view_args() ok inside ViewfieldDefaultFormatter? |
|
After updating core and contrib i kept getting this error:
Switching back to my original approach solved it. Any idea why this happens? |
|
@luksak , by "Switching back to my original approach solved it," do you mean reverting ce911e4? Because I ran into a problem with using my fork where new content does not invalidate the node containing the viewfield. Once I added cache tags like in e45a3a6, it worked perfectly. (FYI the site's core is 8.1.8) |
Fixed deprecated code.
I added cache tags. This needs tests.