Closed (fixed)
Project:
Typed Data API enhancements
Version:
2.0.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Dec 2019 at 06:22 UTC
Updated:
5 Apr 2023 at 21:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dsdeiz commentedWould this happen to work? I'm not sure about the tests though. I've also added the IP address constraint plugin though I guess it might conflict if say core adds the constraint. Mostly copied from
TextData.Comment #3
dsdeiz commentedComment #4
tr commentedHi @dsdeiz. Thanks for the patch. I think it's a good start. I would like to also have methods to retrieve an IPv4 and IPv6 address from the ip_address data type. I think this is a capability we had in D7.
See for example the \Drupal\Core\TypedData\Plugin\DataType\Timestamp data type for how to do this - this involves defining some methods on the type interface and implementing them in the DataType plugin. Then there should also be tests for creating an ip_address from an IPv4 or an IPv6, and also retrieving an IPv4 or an IPv6 independent of how the ip_address was created.
Comment #5
dsdeiz commentedComment #6
dsdeiz commentedYeah, not really sure how this one should be done, sorry. Tried checking the implementation in D7 rules although I'm not finding it.
I wonder if this would work. I just added methods for retrieving and returned NULL if they are not in a valid IP version format depending on the method used.
Comment #7
dsdeiz commentedComment #8
Anonymous (not verified) commentedHello, I have applied this patch and tested it, and I can confirm that this is working for me.
Comment #10
tr commentedComment #11
sharayurajput commentedI reviewed the patch working good looking good to me so we can move this to RTBC
Comment #12
sahilgidwani commentedComment #13
tr commented#6 seems fine but it is old and needed to be re-rolled to bring it up to current standards. Here is a new version of that same patch.
Comment #14
jungleIP address?
getIpV4Address() or getIpv4Address()? getIpv4Address(), + 1
getIpV6Address() or getIpv6Address()? getIpv6Address(), + 1
IP?
Otherwise RTBC +1
Comment #15
jungleComment #16
tr commented#1: Thanks, I missed that.
#2, #3: I don't know. Personally I would choose IPv4 and IPv6, because that is the canonical usage. But Drupal is different. I guess Drupal would demand IpV4 and IpV6, but I'm not sure. Do you really think Ipv4 and Ipv6 are better than (IPv4 and IPv6) or (IpV4 and IpV6)?
#4: No. The Symfony validation class is named "Ip" so we're stuck with that.
Comment #17
jungle#2, #3, I think it depends. If we treat IPv4/IPv6 as a word, then we can go with Ipv4/Ipv6. if we think it's two words -- IP + V4/V6, then it should be IpV4/IpV6,
E.g.
1. LinkedIn, it's a word, not Linked + In,
2. WeChat, it's a word. Not We + Chat.
I would treat IPv4/IPv6 as a word. That's why I prefer Ipv4/Ipv6
Comment #18
jungle>#4: No. The Symfony validation class is named "Ip" so we're stuck with that.
Sorry, it may be unclear. I meant changing
Translation("Ip", context = "Validation"),toTranslation("IP", context = "Validation"),. Not the class name.Comment #19
jungleIn addition to #2, #3, yes, we can not use getIPv4Address/getIPv6Address. See https://www.drupal.org/docs/develop/standards/php/object-oriented-code#n...
Comment #20
tr commentedOK, you have a good argument. I made the changes you suggested. I also added some text to a few documentation comments.
Comment #21
jungleTo me, It's ready. @TR, thank you!
Comment #23
tr commentedCommitted. Thanks!