Sub-issue for meta issue #1880976: [meta] Port examples (including submodules) to D9.4+
Problem/Motivation
We need to demonstrate adding contextual links to entities.
Proposed resolution
Let's add a new module, called contextual_link_example, which implements edit, view, and delete contextual links to the content_entity_example module.
This module will have examples:content_entity_example as a dependency.
| Comment | File | Size | Author |
|---|---|---|---|
| #47 | interdiff.txt | 3.76 KB | mile23 |
| #47 | 2102647_46.patch | 26.69 KB | mile23 |
| #45 | interdiff-43-45.txt | 969 bytes | navneet0693 |
| #45 | 2102647-45.patch | 23.99 KB | navneet0693 |
| #43 | interdiff-2102647-41-43.txt | 3.53 KB | martin107 |
Comments
Comment #1
a_thakur commentedStarted working on this.
Comment #2
marvil07 commentedJust cleaning. If there is a patch please add it.
Comment #3
icanblink commentedLooking into it.
Comment #4
icanblink commentedAdded the patch for porting contextual links example.
Comment #5
icanblink commentedComment #7
Lal_I've rerolled the patch.
Comment #8
navneet0693 commentedAdded tests and did a significant amount changes to patch #7, added theme functions, removed unwanted code, corrected code and now it's fully working !
Comment #10
navneet0693 commentedComment #12
navneet0693 commentedComment #14
mile23Thanks!
Here's some review. More to come on the test.
Should require contextual.
Why do we have a storage class if it's just a stub implementation?
Should not require contextual here.
Comment #15
mile23Can't typehint int for PHP 5.5.
This block never shows up in the block admin page.
As for the tests.... Based on
Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest, it seems we'll need to inherit fromJavascriptTestBaseto get the click that opens the contextual menu.That needs some local dev environment setup: https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial
Comment #16
navneet0693 commentedHey @Mile23, thank you very much your review.
Yes, Storage class is just a stub implementation.
I will work upon for other changes.
Comment #17
navneet0693 commented@Mile23
This does show up. You will have to place it using Block Interface UI.
Comment #18
navneet0693 commentedComment #19
navneet0693 commentedComment #21
navneet0693 commentedI am doing something wrong here,
@Mil23, after observing html results of tests, I observed that contextual links doesn't render on minimal profile . I having less knowledge on how to proceed in this scenario. How can we proceed with tests ?
Comment #22
mile23See #15. Contextual menus are javascript-based, so we have to use functional javascript tests. Here's a test from core: http://cgit.drupalcode.org/drupal/tree/core/modules/contextual/tests/src...
Comment #23
navneet0693 commentedFirst attempt for javascript functional test.
Comment #25
navneet0693 commentedComment #27
mile23Are you sure this class exists?
Comment #28
navneet0693 commented@Mile23 yes! I am attaching a screenshot of HTML output of JS test.
Comment #29
navneet0693 commentedEverything needs to be perfect for tests to pass !
Comment #30
martin107 commentedA minor adjustment
I have dropped t() in favour of $this->t().
Comment #31
navneet0693 commentedThank you @martin. Oops! My bad. Updating it to examples:examples
Comment #32
mile23Coming along...
Needs @defgroup, and an explanation of what this module does and how it does it.
We should have some text on this page to explain what's being accomplished, generally how it works, and what to look at next for specifics.
I doubt these ids will always be the same. We should just load all the CLEEntity objects that are available.
Should be @see and not have a period at the end.
Is there not a generic entity base implementation we can use instead?
We don't use @package.
Comment #33
mile23Comment #34
Lal_working on it
Comment #35
Lal_Still stuck with issue #5 and #3
Comment #36
Lal_Comment #38
navneet0693 commentedNot a correct way of doing this.
Use DescriptionTemplateTrait and $this->description to add in build array.
Please do not remove this.
Did you change something in tests ?
Comment #39
Lal_Comment #41
Lal_Comment #42
Lal_Need to fix few more issues
Comment #43
martin107 commentedJust fixed a few coding standard nits while reading along.
Comment #44
mile23Comment #45
navneet0693 commentedComment #46
mile23OK, so we have way too much stuff here just to implement an entity that we can't edit.
The storage class doesn't actually do anything.
This patch adds a test that demonstrates that we can't save our new entity.
So let's rescope a bit.
Let's add a contextual link implementation to the content entity example.
This means we can get rid of all the entity implementation details from this patch, and worry instead about adding contextual links.
Comment #47
mile23Hah. Forgot the patch.
Comment #49
valthebaldMoving to new examples meta
Comment #50
avpaderno