From 3b026b156684332648fbeb093086618c50f5d272 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Wed, 29 Apr 2020 10:12:38 -0600 Subject: [PATCH] refactor(BaseEntity): Remove virtual inheritance Virtual Inheritance was a rarely used option that added increased complexity and code paths to the code. We are removing it in favor of traditional inheritance. BREAKING CHANGE: Virtual Inheritance (using a `quick` annotation) has been removed and needs to be migrated to traditional inheritance (`extends="quick.models.BaseEntity"`). --- ModuleConfig.cfc | 4 --- .../QuickVirtualInheritanceInterceptor.cfc | 22 --------------- models/BaseEntity.cfc | 28 +++++++++---------- tests/resources/app/models/User.cfc | 2 +- tests/resources/app/models/externalThing.cfc | 4 +-- 5 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 interceptors/QuickVirtualInheritanceInterceptor.cfc diff --git a/ModuleConfig.cfc b/ModuleConfig.cfc index 7c4a3cb9..39eff104 100644 --- a/ModuleConfig.cfc +++ b/ModuleConfig.cfc @@ -27,10 +27,6 @@ component { ] }; - interceptors = [ - { class="#moduleMapping#.interceptors.QuickVirtualInheritanceInterceptor" } - ]; - binder.map( "quick.models.BaseEntity" ) .to( "#moduleMapping#.models.BaseEntity" ); diff --git a/interceptors/QuickVirtualInheritanceInterceptor.cfc b/interceptors/QuickVirtualInheritanceInterceptor.cfc deleted file mode 100644 index 20a56f17..00000000 --- a/interceptors/QuickVirtualInheritanceInterceptor.cfc +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Interceptor for performing virtual inheritance on components with the - * `quick` metadata key. - */ -component { - - /** - * Set virtual inheritence after the instance inspection for components - * with the `quick` metadata key. - * - * @interceptData The struct of intercept data for the - * afterInstanceInspection interception point. - * - * @return void - */ - public void function afterInstanceInspection( required struct interceptData ) { - if ( interceptData.mapping.getObjectMetadata().keyExists( "quick" ) ) { - interceptData.mapping.setVirtualInheritance( "quick.models.BaseEntity" ); - } - } - -} diff --git a/models/BaseEntity.cfc b/models/BaseEntity.cfc index 0f767b12..129c425f 100644 --- a/models/BaseEntity.cfc +++ b/models/BaseEntity.cfc @@ -2818,21 +2818,19 @@ component accessors="true" { * @return void */ function instanceReady() { - if ( entityName() != "BaseEntity" ) { - param this.memento = {}; - structAppend( - this.memento, - { - "defaultIncludes" : retrieveAttributeNames(), - "defaultExcludes" : [], - "neverInclude" : [], - "defaults" : {}, - "mappers" : {}, - "trustedGetters" : true, - "ormAutoIncludes" : false - } - ); - } + param this.memento = {}; + structAppend( + this.memento, + { + "defaultIncludes" : retrieveAttributeNames(), + "defaultExcludes" : [], + "neverInclude" : [], + "defaults" : {}, + "mappers" : {}, + "trustedGetters" : true, + "ormAutoIncludes" : false + } + ); } /** diff --git a/tests/resources/app/models/User.cfc b/tests/resources/app/models/User.cfc index d5f56f06..2b93495b 100644 --- a/tests/resources/app/models/User.cfc +++ b/tests/resources/app/models/User.cfc @@ -1,4 +1,4 @@ -component quick { +component extends="quick.models.BaseEntity" { property name="id"; property name="username"; diff --git a/tests/resources/app/models/externalThing.cfc b/tests/resources/app/models/externalThing.cfc index 38ed77cd..81705365 100644 --- a/tests/resources/app/models/externalThing.cfc +++ b/tests/resources/app/models/externalThing.cfc @@ -1,4 +1,4 @@ -component quick table="externalThings" { +component extends="quick.models.BaseEntity" table="externalThings" { property name="thingID"; property name="externalID"; // the external vendor foreign key @@ -9,4 +9,4 @@ component quick table="externalThings" { function users() { return hasMany( relationName = "User", foreignKey = "externalID", localKey = "externalID" ); } -} \ No newline at end of file +}