Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Similar to #1857376: Provide an area handler that renders an entity it would be also cool to have an automatic entity row plugin for all entities.
Comment | File | Size | Author |
---|---|---|---|
#87 | drupal-1881606-87.patch | 36.33 KB | dawehner |
#87 | interdiff.txt | 8.83 KB | dawehner |
#84 | drupal-1881606-84.patch | 29.43 KB | dawehner |
#84 | interdiff.txt | 2.22 KB | dawehner |
#82 | drupal-1881606-82.patch | 29.45 KB | dawehner |
Comments
Comment #1
dawehnerThis should be pretty fine already.
Comment #3
dawehner#1: drupal-1881606-1.patch queued for re-testing.
Comment #5
dawehnerComment #6
dawehner#1: drupal-1881606-1.patch queued for re-testing.
Comment #8
dawehner#1: drupal-1881606-1.patch queued for re-testing.
Comment #10
dawehnerSo the basic problem here is that CachePluginBase uses $display_handler->output which is currently a render array.
If we convert it to a string, we have problems during rendering, because we expect a render array there.
Comment #11
olli CreditAttribution: olli commentedLooks like #1 almost works. I do not see any problems with or without caching, but installer failed to find ViewExecutable in views.module on line 832.
Comment #12
dawehnerInteresting, thanks for describing the error. This seems to be something new relative to before.
I provided a fix, but does the cache tests of views run for you?
Comment #14
olli CreditAttribution: olli commentedRight, did not try that test before and same exceptions here. Which part of the patch is causing that test to fail?
Nothing to help there but i noticed "Undefined index: in Drupal\views\Plugin\views\row\EntityRow->summaryTitle() (line 115)" in views ui when adding a view with entity:taxonomy_term. Also:
Views ui thinks the id should be something like entity:$entity_type.
status
id
Comment #15
dawehnerThanks for all this reviews!
Oh right, that change have to be made as well.
Comment #17
olli CreditAttribution: olli commentedLooks like serializing the viewsData property in ViewsEntityRow is causing that failure.
Comment #18
dawehnerYou are right, it feels like this bits us in all different kind of places already.
Comment #19
olli CreditAttribution: olli commentedMaybe we should to implement Serializable in things we cache, but that is probably out of scope here. For this issue:
- Moving the base class left few occurences of "Drupal\system\Plugin\views\row\Entity" in the subclasses.
- What about making EntityRow::defineOptions set the first view mode as default to fix the notice in #14?
Comment #20
dawehnerWell, I have no clue at all, how to serialize a PDO connection. Afaik this is just impossible by design, but if we could do it, then we should do in core directly.
Fixed your two comments and moved the file into the views folder.
Comment #21
dawehnerTotally screwed the patch.
Comment #22
jenlamptonI'm attempting to create a view of taxonomy terms, where I'm showing the full view mode.
In the views wizard, I select "taxonomy term" and check the box for "create a page". Under "display format" If I choose "unformatted list" of "taxonomy term" and click "save & edit" I get the following error:
leaving as needs review incase these errors have nothing to do with your magic :)
Comment #23
EclipseGc CreditAttribution: EclipseGc commentedWhy not remove the annotation from Drupal\user\Plugin\views\row\UserRow and do
instead? This gives other entity providers a really clear way to provide an override mechanic for the entity row in core, and should reduce some of the head scratching with the unsets.
Also, you'd probably move that file out of a directory that will get parsed for annotations, but I don't think that's a requirement.
Eclipse
Comment #24
damiankloip CreditAttribution: damiankloip commentedI'm not sure about Eclipses comment, so I will let you decide on that :) Seems a bit weird to have a plugin we are using but intentionally not parsing an annotation definition for it?
We can also move the views_data and create a variable for it outside the foreach loop.
Comment #25
EclipseGc CreditAttribution: EclipseGc commentedWell I suggested we remove the annotation for that class as well.
Eclipse
Comment #26
dawehner@jenlampton
Thanks for testing the patch! I got a different error when selecting taxonomy terms. Your error seems to be referring to an old version of the patch, or some kind of cached views data. Maybe it helps if you clear the views caches under admin/structure/views/settings/advanced.
@eclipseGC
That's a good idea, as it makes the classes easier to read. One disadvantage though is, that you don't longer have a good an easy example for other people, what to put into the plugin data. Let's see what the testbot tells us.
Comment #27
EclipseGc CreditAttribution: EclipseGc commentedYup, like that (hope it passes since I'm commenting before hand).
Since it's specific to entities and rows, we don't need another example. This is saying "Extend EntityRow, and write your own entity's needs, and then alter it in" which should be pretty easy to follow, and hopefully gives greater insight into the fact that you can do this with almost any plugin, which is ridiculously empowering as a developer.
Eclipse
Comment #29
dawehnerThis should fix a lot of them.
Comment #31
dawehnerI'm glad that one was easy to fix.
Comment #32
damiankloip CreditAttribution: damiankloip commentedI think we should say Replaces or overrides instead of removes.
I still find this odd that we are not having an annotation here, but it also makes sense just to swap out the class.
Oooo, is this deprecated now? I say leave it in because I hate the proposed 'new' way.
This is already defaulted to an array in the class definition.
I think I mentioned this above somewhere but we can move the
drupal_container()->get('views.views_data');
outside the foreach loop.I guess this should lose the @todo or it should say 'Replace with entity_test implementation when it can be rendered.' or something.
Comment #33
aspilicious CreditAttribution: aspilicious commentedDoc code mismatch. Nothing gets removed. Only the class gets changed. :)
Comment #34
dawehnerThanks for the feedback, both!
Comment #35
aspilicious CreditAttribution: aspilicious commentedcomments :)
Comment #36
dawehnerHe, true
Comment #37
damiankloip CreditAttribution: damiankloip commenteds/Replaced/Replace - Sorry!!
Comment #38
dawehnerNo problem!
Comment #39
rlmumfordThis might need to be in quotes because of the ':'. I don't know how much testing there is for this sort of thing yet, so I'm not sure how to check if all is ok.
As above, also a few more times throughout the patch.
The rest looks good to me!
Comment #40
damiankloip CreditAttribution: damiankloip commentedWell if it didn't parse the yaml correctly without quotes you definitely wouldn't be getting a green patch :)
I guess we should do whatever would happen when the configuration system writes this normally with the yaml dumper, which I have a feeling might wrap it in quotes, but really it doesn't matter.
Comment #41
dawehnerAfter manual saving a view, the yaml parsed used '', so let's do it here.
Comment #42
EclipseGc CreditAttribution: EclipseGc commentedI'm 99% certain it wraps in single quotes.
Eclipse
Comment #43
dawehnerHey :)
Comment #44
jenlamptonerm, I think it needs a reroll. Stuff explodes now, I can't even get to views page to clear views caches.
Comment #45
dawehner@jenlampton
You are right, there has been some recent changes in the plugin system, which forces that.
Sadly everyone who uses /node have to reinstall drupal with that change, as the /node view uses a not defined plugin ID with that.
interdiff sadly failed on that files
Comment #47
dawehnerForgot the move of the file and broke the yml file.
Comment #48
olli CreditAttribution: olli commentedIs it ok not to alter module key?
Should this skip types which cannot be rendered?
Area?
Can we now use entity_test_render?
Do we have an issue for this? Until it is fixed, should we inline plugin types here or include_once the file if the class does not exist?
Comment #49
dawehnerThats a great idea, all of the comments, so let's see whether it works.
Comment #50
EclipseGc CreditAttribution: EclipseGc commentedThat's a really interesting idea. I'll be watching the development of this concept.
Comment #52
dawehnerJust to summarize: The problem is that the entity_test_render entity does use the entity_test table for storage, which causes all kind of different issues in various places ... so it seems to be that we should use taxonomy for now, in order to make progress and fix the rest in another follow up.
Comment #53
olli CreditAttribution: olli commentedCould this use ViewUnitTestBase?
This would be nice. I thought about changing 'entity type' from 'entity_test' to 'entity_test_render' in entity_test_views_data().
I'm fine with using taxonomy, it works.
Comment #54
dawehnerWe could though it would be probably way harder with taxonomy
Comment #55
dawehnerSo yeah let's use taxonomy for now, and yeah you are right, you can use ViewUnitTestBase for it.
Comment #56
joelpittetAfter applying #55 patch I got a nasty 'looking' error on clicking edit on an enabled "Taxonomy term" view.
Path:
admin/structure/views/view/taxonomy_term/edit
Error produced:
Drupal\Component\Plugin\Exception\PluginException: The plugin (node) did not specify an instance class. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 62 of core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).
To make extra sure it wasn't caching I did the following:
Cleared cache + views cache cleared + truncated all cache tables + sudo rm -fr sites/default/files/php/
Comment #57
dawehnerThat's not an issue. We don't update yml files from HEAD to HEAD, so that's not an issue.
Comment #58
joelpittet@dawehner, I am new to the yml files setup, is there something I need change to properly test this patch?
Comment #59
dawehnerReinstall drupal is the only easy way to do it.
Comment #60
dawehnerLabel it!
Comment #62
dawehnerThis should fix it.
Comment #64
dawehner#62: drupal-1881606-62.patch queued for re-testing.
Comment #65
olli CreditAttribution: olli commentedBonus with this patch is that mymodule_views_plugins_[any plugin type]_alter can go into mymodule.views.inc.
Comment #66
catchShouldn't the container be got from \Drupal::service() now?
Comment #67
dawehnerOH totally, fixed that.
Comment #69
dawehner#67: drupal-1881606-67.patch queued for re-testing.
Comment #71
olli CreditAttribution: olli commentedWhere did ViewsEntityRow go?
Filed #1968090: During installation the moduleHandler calls hook_hook_info without having the classloader setup properly.
Comment #72
dawehnerViews should be clever enough to figure that out :p
Comment #74
jibranYou missed a place.
Comment #76
dawehnerGood catch!
Let's also fix the test failure :)
Comment #77
jibranRTBC as per #66.
Comment #78
catchCould this be moved to a separate issue? Is there one already for the hook_hook_info() invocation without the classloader being properly available?
Comment #79
dawehner#1975354: hook_hook_info() might be invoked even the namespace hasn't been registered yet. ... let's see whether it passes. It could be that this fix is not needed anymore, because some part of the module handler changed in the meantime.
Comment #80
dawehnerSo this should work now.
Comment #81
olli CreditAttribution: olli commentedLooks like the test is not in the patch anymore..?
{@inheritdoc}
Could use \Drupal::entityManager()?
Missed this one last time.. I still think it should check for hasController($entity_type, 'render') here.
Comment #82
dawehnerThanks for the review!
Additional some cleanup was involved + the entity manager got injected into the plugin.
Comment #83
olli CreditAttribution: olli commentedFound one bug while testing manually:
'display_type' -> 'display_types'
Space missing after last comma =)
I guess entity_test is not needed anymore.
Comment #84
dawehnerOh this relative recently changed. Good catch!
Comment #85
olli CreditAttribution: olli commentedGreat! Back to RTBC.
Comment #86
tstoecklerSorry to push this back, but I'm missing some API documentation on the new hook_views_plugin_PLUGIN_TYPE_alter(&$data) hooks.
Comment #87
dawehnerYes, there should be new docs. Thanks. I hope the examples are actually sort of useful.
While doing that renaming $data to &$plugins made sense for me.
Comment #88
tstoecklerWow, that is one awesome set of docs!
Comment #89
tim.plunkett#87: drupal-1881606-87.patch queued for re-testing.
Comment #90
dawehner#87: drupal-1881606-87.patch queued for re-testing.
Comment #92
dawehner#87: drupal-1881606-87.patch queued for re-testing.
Comment #94
tstoecklerWeird bot x-post. Still RTBC, though.
Comment #95
alexpottCommitted bd1f226 and pushed to 8.x. Thanks!
Comment #96
dawehnerYou are the hero!!