Closed (fixed)
Project:
Payment
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2013 at 10:30 UTC
Updated:
8 Feb 2015 at 22:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
xanoComment #2
xanoThis depends on #2294745: Add a field type for plugins.
Comment #3
xanoConsider adding an interface and a trait for plugins to implements, so they can notify the field of changes and both can be kept in sync with each other.
Comment #4
xanoThis patch introduces the field types, but does not yet convert the plugins on payments to fields, nor does it remove current storage code.
Comment #5
xanoComment #6
xanoComment #8
xanoonChange()turns out to be *extremely* unreliable for doing anything, assetValue()'s documentation implies the$notifyparameter should beFALSEmostly/only when setting a child property's value from a parent. However,TypedDataManagersets$notifytoFALSEfor no documented reason.To work around this, I think the only option is to create special data types for each of the field's properties so we can explicitly notify the field (which is the parent) when a property's value changes and as such reliably synchronize all properties.
Comment #9
xanoSeeing as we had to enforce a plugin instance to exist for every field item at all times anyway, it's probably better if the plugin ID and plugin configuration properties are converted to computed properties that are only used for storage, because removes the need for synchronization between the plugin instance and the field item and between the field item's properties.
Comment #10
xanoThis is with computed properties. As I should have expected, this won't work without entity storage modifications, because the storage cannot set the values for the computed properties. Just storing a serialized plugin could work, but if we want to be able to query the field, we'll have to store the plugin ID as well.
Comment #11
xanoWe can't serialize the entire instance, because it's an instance of a plugin class and plugins by nature are not always available.
Comment #12
xanoLet's try a slightly different approach: three field item properties, of which two proxy calls to the instance that must always exist as the value of the third property. Proxying prevent synchronization problems, while always having an instance (unless the item has no value) keeps the code simple enough to maintain.
Patch is not ready and some tests still fail.
Comment #16
xanoRe-roll.
Comment #18
xanoComment #20
xanoMany plugins are payment-aware. However, now they no longer have to be set through the payment entity, but can also be set through field API. A simple
onChange()on payment entities did not work, becauseTypedDataManagercreated field items and sets their values before they are set on the parent. This means the parent (the payment) is notified, wants to grab the instance from the field, but at that point the field is not assigned to the parent yet (one-way reference) and we end up in an infinite loop. EnterPaymentAwarePluginBagItemBase. It doesn't seem to solve all problems yet.*Puts on his thinking cap*
Comment #22
xanoThis needs a modification to
FieldItemBase:Comment #23
xanoThis includes the fix from #22 added to
PluginBagItemBase.Comment #25
xanoComment #26
xano