Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
shortcut.module
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
27 Mar 2014 at 17:15 UTC
Updated:
29 Jul 2014 at 23:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
wim leersComment #3
e0ipsoComment #4
e0ipsoThis patch iterates on #1 fixing the tests to reflect the changes. I pair programmed this with @rvilar.
Comment #5
e0ipsoComment #6
plopescThis looks good to me...
Thank you guys!
Comment #7
wim leers@e0ipso: awesome, thank you! :)
This is not actually done yet though, as the issue summary says: "Once test failures are fixed, look into converting more base fields."
ep0ipso, could you maybe convert the "path" base field in a similar way? :)
Comment #8
marcvangendOne small detail:
The current form has no description below the name field and this description doesn't add any value. It should be removed.
@ e0ipso: I'm un-assigning this issue for now, but if you're still actively working on it, please feel free to re-assign it.
Comment #9
e0ipsoI'm still working on it. I am removing the form validation in favor of a custom constraint. Please, consider this re-assigned back to myself.
Comment #10
marcvangendJust a thought - Perhaps it's easier to get your changes committed if you split it into two separate issues, one for the conversion to base-fields-with-formatters, another for reworking the validation.
Comment #11
berdirI'm fairly sure that @amateescu wants to use the link field type for this as soon as that is in, I wouldn't waste any time on the current path related fields.
Comment #12
e0ipsoI applied formatters to the path field and added the
field_prefixandfield_suffixsettings to theStringItem. I run into some challenges due to the fact that the path field is computed and therefore was not being displayed in the entity form by default and the value was being cleared since computed fields are considered to be empty.As per the validation I removed the dependency on the form, provided that we should be using constraints for this -as agreed with @Wim Leers- in Szeged. To do so I had to declare a new custom constraint and fix a bug where empty keys were not being processed appropriately (in my understanding of PHP $array[''] should be the same as $array[NULL]).
I hope this constraint serves as an example for other issues needing to validate the field values. Finally I added a test to assert the failure when a Shortcut link tries to use a path that doesn't exist.
As per the previous comment suggesting to remove the
->setDescription(…), I'm not sure that is such a good idea since we would be deleting the description from the field definition just to remove the markup from the widget. If it's that important we can alter the form element in theShortcut::form(), I you feel that is worth it I'll be glad to provide a new patch with that. Also https://drupal.org/comment/8623909#comment-8623909 may be relevant to this.PS: @Berdir, I did this on my plane back to home, so I already wasted my time… :-( Also I was under the impression that the link field did not support internal links yet, but I may be wrong.
Comment #14
berdirThe issue I meant is #2054011: Implement built-in support for internal URLs, you are completely correct about not supporting internal path but that issue will change it. And then Shortcut will change quite a bit.
Comment #15
e0ipsoUpdated patch to remove custom constraint for the validation part.
Comment #16
yched commented$this->getPath(), then ?
Looks a bit weird, is that temporary pending refactorings in another issue ?
In that case a @todo comment pointing to the issue would be nice.
At any rate, would deserve a comment expliciting that this exposes the 'path' field that would otherwise be left out by ContentEntityBase::getProperties() since it's 'computed', and most of all *why* 'path' needs to be part of getProperties().
Looks overly verbose, other isEmpty() methods in other FieldItem classes do not bother with searching both $this->properties and $this->values, they just use $this->get($property) or directly the $this->{$property} shortcut.
Comment #17
e0ipsoActually it was only needed in order to the provided value to be passed along when using constraint based validations. Since I completely got rid of it (as per @Berdir suggestion) this method should not be needed anymore.
Comment #18
yched commentedThanks !
Ok, then what puzzles me is why the "path" field is computed while it has a widget to make it editable.
"Editable by user input" and "computed" seem mutually exclusive ?
Comment #19
e0ipso@yched I *think* that we initially had a computed field that populated the custom path form element.
The real fields are the ones with the route information, not the path, but since it's cumbersome to have users adding route names and such there was this helper form element that generated that info from a path. To populate that form element we were using the value from the computed field. The only thing the computed element did was generate a path based on the route information.
So we went from a custom form element that generated the route info + a computed field that generated the path from the route to a computed field that shows its widget in the entity form.
Does that make any sense?
BTW: I did not expect this many intricacies in a novice issue :-P, although I have to admit it was fun playing with custom constraint validators.
Comment #20
berdirYeah, the Novice part about this issue for me was fixing the existing tests :)
Again, I really think we shouldn't waste time on the path stuff in the current state, it will change anyway. #2054011: Implement built-in support for internal URLs is RTBC now and a beta blocker, so hopefully it will get in soon and then we can have a follow-up issue to refactor shortcut to use it and use that widget, which should then more or less just work.
Comment #21
e0ipso@Berdir, this seems to contradict #7. Is the patch in #4 good then? We may need to re-test it then.
Comment #22
berdirIMHO yes, we should go back to #4. The link issue has been committed in the meantime, so we can start to use it, but I don't think we should do it here. So either convert it first and postpone this issue on it or just get this in without the path and then use the widget form the start in the other issue.
What can be further cleaned up in #4 are the #type value form elements there, they are useless.
Comment #23
e0ipsoThe following patch is the same as in #4 without the #type value form elements, as suggested by @Berdir.
Comment #24
berdir+1 from me to move forward with this, someone else wants to set it back to RTBC as it's based on my suggestion?
Comment #25
amateescu commentedI think it's fine to move forward with this as-is and leave the 'path' part to another issue that makes shortcuts use the improved link field.
Comment #26
berdirBtw, I started doing exactly that in #2235457: Use link field for shortcut entity. This might even remove the separate title field depending on what we want, but there are quite a number of bugs related to the link field that need to be fixed before that can happen, so let's get this in while working on that.
Comment #27
alexpottCommitted b0fb47f and pushed to 8.x. Thanks!
Comment #29
alexpottComment #31
wim leers