Skip to content

Adding cache tags#2

Open
luksak wants to merge 3 commits into
wellebee:8.x-2.xfrom
luksak:adding-cache-tags
Open

Adding cache tags#2
luksak wants to merge 3 commits into
wellebee:8.x-2.xfrom
luksak:adding-cache-tags

Conversation

@luksak

@luksak luksak commented Jun 9, 2016

Copy link
Copy Markdown

I added cache tags. This needs tests.

@Berdir

Berdir commented Jun 13, 2016

Copy link
Copy Markdown

Should also include cache contexts and max-age. Try using something like CacheableMetadata::createFromObject($view)->applyTo($build);

@Berdir

Berdir commented Jun 13, 2016

Copy link
Copy Markdown

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:

$view = Views::getView('view_id');
$build = $view->buildRenderable('display', $arguments)

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.

@luksak

luksak commented Jul 29, 2016

Copy link
Copy Markdown
Author

Alright, tried to implement this. Does this look right? Is the usage of _viewfield_get_view_args() ok inside ViewfieldDefaultFormatter?

@luksak

luksak commented Sep 6, 2016

Copy link
Copy Markdown
Author

After updating core and contrib i kept getting this error:

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

Switching back to my original approach solved it. Any idea why this happens?

@marcus-n3rd

Copy link
Copy Markdown

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

@marcus-n3rd marcus-n3rd mentioned this pull request Oct 24, 2016
kviatkovskyi referenced this pull request in summitmedia/viewfield Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants