/**
 * Defines a common interface for entities that have an owner.
 *
 * An owner is someone who has primary control over an entity, similar to
 * owners in Unix file system access. This may or may not be the entity's
 * original author. The owner may also have less permissions than other users,
 * such as administrators.
 */
interface EntityOwnerInterface {

And the uid field should setDefaultValueCallback.

Comments

jian he created an issue. See original summary.

jian he’s picture

Issue summary: View changes

And the uid field should setDefaultValueCallback.

tr’s picture

Yes.

The history, if you're interested, is that Order.php was written BEFORE EntityOwnerInterface even existed. Now that we have that core interface we should use it ...

OrderInterface should extend EntityOwnerInterface, and the getUser(), getUserID(), setUser(), setUserID() methods should be renamed to xxxOwner() and xxxOwnerID() to agree with that new interface and of course all uses of those methods in other parts of Ubercart need to be updated.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new26.74 KB

This patch implements EntityOwnerInterface but does not add setDefaultValueCallback to the uid field. This is because we currently always specify the uid whether the order is created on the front or back end, and I think OrderStorage::create() needs refactoring so we have default value callbacks for all the fields - primary_email will be interesting as we need to know the uid in order to discover the email address.

Status: Needs review » Needs work

The last submitted patch, 4: entityownerinterface.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new26.76 KB
longwave’s picture

StatusFileSize
new619 bytes

Status: Needs review » Needs work

The last submitted patch, 6: entityownerinterface.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new26.75 KB
new613 bytes

Alright, stop trying to be clever.

longwave’s picture

Title: the Order entity should implement the EntityOwnerInterface » Order entity should implement EntityOwnerInterface
longwave’s picture

StatusFileSize
new32.78 KB
new7.02 KB

I think it's safe to move OrderStorage::create() into Order::preCreate() and add the callback. We can also refactor the customer information pane to not set the user ID or email now, and add a test to confirm this all still works as expected.

edit: still need to remove the hidden value from the customer info pane

Status: Needs review » Needs work

The last submitted patch, 11: entityownerinterface.patch, failed testing.

tr’s picture

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new34.77 KB
new2.19 KB
longwave’s picture

Status: Needs review » Fixed

Committed #14.

  • longwave committed 7cf52d5 on 8.x-4.x
    Issue #2625288 by longwave: Order entity should implement...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.