Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
shortcut.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
28 Jun 2013 at 14:46 UTC
Updated:
29 Jul 2014 at 22:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
marvin_b8 commentedI'm not sure but i think we need to use setId() in this special case because we use the functionality from a setid() method in the class shortcut
Comment #3
marvin_b8 commentedi work on it
Comment #4
michaelhiiva commentedComment #6
johnennew commentedHi - I've rerolled the patch for latest 8.x branch and made some changes for review.
I do not believe that changes are required to Entity and ConfigStorageController which were proposed previously.
Biggest problem I see is that of removing the public modifiers on the id, label and links parameters of the ShortcutSet class. The ConfigEntityBase class uses reflection in its getExportProperties method to get all public parameters for export. We could override the getExportProperties but I wonder if this is the right approach?
Second issue is the $links parameter on the ShortcutSet class. It is used in two different ways to store two different types of data which feels really wrong - but maybe this is a standard pattern? Usually it is an associative array with the key as the MenuLink UUID and the value as the MenuLink object. However, in preSave and during Entity creation, it is a string array of UUIDs. I broke out the conversion from UUIDS to obejects into its own function but maybe there is a cleaner way to do this?
I'm at DrupalCon Prague code - in the coder lounge Thurs and Fri if anyone has a moment to go through this with me (ceng_ on irc).
Thanks!
Comment #7
berdirYes, I'd just leave those as they are for now. We're removing them for content entities, as they're not really there anyway, but let's not touch them here I think. But if we want to, I think @timplunkett knows how to do it.
Ok, this is weird, not sure what to do about it yet.
What we usually do is store the raw values (like UUID's) but getter methods then load the entities or whatever.
Then this shouldn't be needed I think?
Comment #8
johnennew commentedThanks @berdir,
I think you are suggesting that $this->links should contain just the UUIDs (and so be renamed $link_uuids). Then the getMenuLinks function will load all the MenuLink objects when called.
Should I worry about caching the list of MenuLink objects via a private variable on the StorageSet class? That would make two variables which would need to be kept in sync, $this->link_uuids and $this->menu_links.
Comment #9
johnennew commentedOK, so this patch contains ..
Happy to chat about this with anyone in Prague today - I'm in the coder lounge!
Comment #10
johnennew commentedThe previous patch in #9 has a coding standards issue. The class parameter $menu_link_uuids should be camel case $menuLinkUuids. Attached patch fixes that.
Comment #12
johnennew commented#10: shortcut_expand-with-methods_2030657_10.patch queued for re-testing.
Comment #13
johnennew commentedChanged the menu_link_uuids variable back to links.
It needs to be camelCase because it is a class property but needs to be underscore case because reflection puts it into a CMI export file. Needs to be one word so works in both cases, links makes most sense.
Comment #14
johnennew commentedI've changed the modifiers to protected and overridden getExportProperties() like the \Drupal\views\Plugin\Core\Entity\View class does as @tim.plunkett suggests here:
https://drupal.org/node/2016679#comment-7659387
Comment #15
daffie commented@ceng: I am sorry for you that your patch did not get a review earlier.
You patch was so out of date that I made a new patch.
Hope that my new patch get reviewed a little bit earlier. ;)
I also have a question: The shortcut entity has a computed base field called "path".
Does there need to be a function getPath() or not?
Comment #16
abelassChecked the code an tested the form Add Shortcut
Patch ok
Comment #17
amateescu commentedThe patch looks good to me as well, RTBC++.
Comment #18
catchCommitted/pushed to 8.x. Just a note I manually handled the file permission issues in the patch.