Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding cache tags #2

Open
wants to merge 3 commits into
base: 8.x-2.x
Choose a base branch
from
Open

Conversation

luksak
Copy link

@luksak luksak commented Jun 9, 2016

I added cache tags. This needs tests.

@Berdir
Copy link

Berdir commented Jun 13, 2016

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

@Berdir
Copy link

Berdir commented Jun 13, 2016

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
Copy link
Author

luksak commented Jul 29, 2016

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

@luksak
Copy link
Author

luksak commented Sep 6, 2016

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

@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