Closed (fixed)
Project:
Examples for Developers
Version:
8.x-1.x-dev
Component:
Menu Example
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2013 at 23:00 UTC
Updated:
25 Jan 2018 at 23:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
marvil07 commentedComment #2
marvil07 commentedUhm, not yet working. Current problem seems to be that tools menu(the default menu used by D8) is not shown on any region by default, need to investigate about it.
So: Make the tools menu (or define another new menu) and add it to sidebar left region on the theme to show the links and be able to link.
Comment #3
kgoel commentedGoing to work on this during DrupalCon lab.
Comment #4
kgoel commentedI have worked on it on my sandbox and later in the evening, I will upload the patch for what I have done so far.
Comment #5
kgoel commentedwork in progress here - https://drupal.org/sandbox/kg/2097629
Comment #6
mile23Care to offer a patch please?
Comment #7
mile23Change notice: https://drupal.org/node/2184797
Comment #8
mile23A straight port of menu_example's tests from 7.x-1.x.
These should fail. :-)
Working on this issue got me working on SimpleTest: #2234295: drupalLogin() crashes where it should fail. #1452896: PHP notice in clickLink if link does not exist
Comment #9
mile23Comment #11
mile23New failing tests from #2277667: Port D7 Tests To D8 for menu_example. Consider these the 'official' ones, and dev your heart out with them.
Comment #12
mrjmd commentedI've got some time in the coming week to try to make some progress on this. I'm going to attempt to contact kgoel directly before assigning this issue to myself. kgoel, if you see this first, have you made any progress beyond what is in the link in #5?
Comment #13
kgoel commentedmrjmd- I worked on this during DrupalCon Prgaue so what I have in my sandbox is probably stale anyway.
Comment #14
mrjmd commentedOkay, I am going to assign this to myself for now and will try my hand at an upgrade. This will be my first D8 module upgrade so it's going to be a learning experience.... I'll either submit a patch or explain that I failed miserably and take the issue out of my name by next week.
Comment #15
mile23Keep in mind that there are a bunch of changes to the menu system, the most important being hook_menu() replaced with *.menu_link.yml: https://drupal.org/node/2223291
Also check the PHPUnit Example module for a template for testing menu links.
Thanks!
Comment #16
kgoel commentedPlease note that this patch is old and there has been change in routing system including adoption of PSR-4.
Comment #17
mrjmd commentedJust wanted to post a quick update on my progress, which can currently be followed here: https://github.com/mrjmd/menu_example
Overall, I think most of this is functionally complete and working. I gutted the old module and previous patches because pretty much everything has changed. The only thing that remains at this point from the D7 version is the implementation of hook_permission()!
I'm going to continue working on this but here's what I know is still incomplete:
Once I get tests and documentation included I'll roll a patch, unless someone would like one now.
Also I'm keeping an eye on https://www.drupal.org/node/2256521; I think it's going to break a good bit of my work.
Comment #18
mile23Also, wow... #2256521: [META] New plan, Phase 2: Implement menu links as plugins, including static admin links and views, and custom links with menu_link_content entity, all managed via menu_ui module is pretty major. Nothing like a last-minute re-architecting. :-)
Thanks.
Comment #19
mile23Un-assigning. Please re-assign if you're still working on this.
Comment #20
andrew.mikhailov commentedComment #21
andrew.mikhailov commentedComment #22
mile23Basically the previous patches don't work because they don't use routes. We're also very close on #2277667: Port D7 Tests To D8 for menu_example which should be the baseline for behavior in this issue.
Comment #23
mile23We have working failing tests now from #2277667: Port D7 Tests To D8 for menu_example
I've closed that issue and the patch here is the patch from that issue.
Proper git attribution for that issue:
Comment #25
Lal_I am creating fresh patch for this
Comment #26
Lal_Ported few files.
Comment #28
Lal_Well, I've ported some of the examples, But I am still facing some issues which are
1) Creating the primary and Secondary tab.
2)Processed Placeholder Arguments.
3)Title Callback, instead of username I was only able to show userid.
4)Ports for the callback only , custom access menu item are not made.
Comment #29
Lal_Well, It is a working patch of Menu example. @navneet0693 and @vaibhavjain thank you for the guidance.
Comment #30
Lal_Comment #34
Lal_Comment #35
mile23Thanks, @AbhishekLal :-)
There are probably other coding standards issues, but let's start here:
Bunch of white space errors.
This should use a translatable template. See BlockExampleController (and block_example/templates/description.html.twig)
These docblocks should say something. :-) https://www.drupal.org/docs/develop/coding-standards/api-documentation-a... Explain what the controller method is demonstrating.
Extraneous docblock.
These tests aren't run because they use the wrong PSR-4 file mapping. This test file should be in /menu_example/tests/src/Functional/MenuExampleTest.php
That should map to the namespace Drupal\Tests\menu_example\Functional
Remove this method. The other tests will fail if the module is not installed.
Comment #36
navneet0693 commentedHey @AbhishekLal thats a great work and a lot of work :) thanks for you efforts !!
Adding to what @Mile23 pointed to, I am adding few points here :)
Extra white space.
Extra line.
//s /examples/menu_example/permission to /examples/menu-example/permission to main consistency :) and also Drupal 8 use - instead of _ in paths.
Use $this->t() instead of t()
More meaningful variable names will look good :)
Use % for replacement here.
Read more about placeholders here: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Rend...
Commented code ???
//s on.hook_menu to on hook_menu
We might need to update description ?
Extra line, this can be utilized to leave description.
One line before function ending bracket and one after it will look good.
Comment #37
Lal_@Mile23 and @navneet0693 I was able to solve some issues you guys have mentioned, I had a tough time with 2nd one in #37 and some are yet to be completed.. This is a working patch..
Comment #38
mile23Setting needs review to run the tests.
Comment #39
navneet0693 commentedAdding few things, I will upload a patch soon.
Comment #40
navneet0693 commentedComment #41
Lal_The patch applied properly and working correctly, thank you so much.
Comment #42
mile23If you check the console output of the last test run, you'll see that no menu_example tests ran: https://dispatcher.drupalci.org/job/drupal8_contrib_patches/8470/console
Comment #43
navneet0693 commentedMile23 is right, I must have missed something :-( .
Comment #44
navneet0693 commentedComment #46
navneet0693 commentedComment #48
mile23I think the problem is that the minimal profile doesn't show the tools menu block. Though I could be remembering incorrectly.
Comment #49
navneet0693 commented@Mile23 I am not sure if that is the problem. Quoting the comment from queue_example and also procedure is same as in other examples.
Comment #50
mile23We also have http://cgit.drupalcode.org/examples/tree/tests/src/Functional/ExamplesBr... to deal with this very issue. :-)
Comment #51
navneet0693 commentedComment #52
navneet0693 commentedComment #53
navneet0693 commented@Mile23, and now we know why the tests were failing, I was able to produce this when i installed drupal core dev (8.4.x) and ran the test. Somehow title were being read from
.links.menu.ymlin 8.3.x which were without quotes ( see interdiff.txt ) but not on 8.4.x !Thanks your hint on IRC, i was able to solve this.
This patch is ready for review.
Comment #54
mile23Nice.... Getting closer. :-)
All of these YAML files need a ton of comments to explain the relationships between the different items.
For instance, the tab examples need to explain how they're set up as tabs.
There has to be some way to do this with introversion, so that all the secondary tabs can be one method that knows which tab it should represent.
These methods need to @see each other. They also need to explain that they're connected by the yaml specification.
This statement isn't accurate. We specify a title callback in the yaml.
This kind of thing creeps me out. :-) Are we sure that sanitization is applied somewhere else?
Should explain what the route subscriber is listening for, and what it will accomplish.
Wrap to 80.
menu_example
It seems like we've defined more routes than are tested here.
Comment #55
mile23Definitely want to include this information: #2384383: "Content Entity Example: Contact Listing" in Tools Menu
Comment #56
navneet0693 commentedComment #57
navneet0693 commented@Mile23 For point 5: We are using following, which I think should do the work.
Comment #59
navneet0693 commentedI am sorry, I forgot to update tests, that's why previous tests got failed.
Comment #60
Lal_Patch applied properly and working great!!
Comment #61
mile23Looking good... Just a few things:
This isn't linked or mentioned in the description page or the module docblock.
Needs a test that shows denial of access if you don't have the right permissions.
Needs an assertion that you can see the page if you have the right permissions.
Comment #62
mile23Comment #63
navneet0693 commentedThanks @Mile23 for review, I have added the suggested changes, and it's getting better ;-)
Comment #64
Lal_Patch applied properly
Comment #65
mile23Thanks. Getting closer....
These should all be
requirements:
_permission: 'access content'
We want to generate these links using Url::fromRoute() and/or Link::createFromRoute().
You can see how to do it here: http://cgit.drupalcode.org/examples/tree/ajax_example/src/Form/Dependent...
Inject the service. We should also change the title so it says something like: "The new title is your username: user".
Mmm. Copypasta. :-)
We should use routes in the test. That way the test still works if we change the path.
$this->drupalGet(Url::fromRoute(route.name));
href assertions like this:
$assertion->linkByHrefExists(Url::fromRoute($route)->getInternalPath());
Also PHPCS says:
Comment #66
Lal_issue no 1,2,3,4 is done and made few changes in the test... Hope it works
Comment #68
navneet0693 commentedWrong routes here.
Comment #69
Lal_Comment #71
Lal_Comment #72
Lal_@navneet0693 thanks for the hints and please review
Comment #73
mile23Thanks, looks great. Just needs that final push...
Comment #74
mile23Managed to lose the test of the route that requires an authenticated user.
Comment #75
mile23Added test case for examples.menu_example.custom_access_page.
Comment #77
mile23Looks fixed to me. :-)
Thanks, everyone!