|
| 1 | +## Overriding Core Wheels Methods (Wheels 3.x) |
| 2 | + |
| 3 | +In Wheels 2.5, developers could override core framework methods (such as `findAll`) in their models and call the original Wheels implementation using the `super` scope. |
| 4 | + |
| 5 | +Due to internal framework restructuring in Wheels 3.0, this behavior no longer works using the traditional `super.methodName()` syntax. To restore this capability in a predictable and explicit way, Wheels now provides a new **`super`-prefixed method convention**. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### Wheels 2.5 Behavior |
| 10 | + |
| 11 | +In Wheels 2.5, overriding a core model method and calling the original implementation looked like this: |
| 12 | + |
| 13 | +```javascript |
| 14 | +component extends="Model" { |
| 15 | + |
| 16 | + function findAll() { |
| 17 | + // custom logic here |
| 18 | + |
| 19 | + return super.findAll(); |
| 20 | + } |
| 21 | + |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +This worked because Wheels core methods were directly accessible via the `super` scope. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +### Why This Changed in Wheels 3.0 |
| 30 | + |
| 31 | +Wheels 3.0 introduced a significant internal reorganization of the framework to support: |
| 32 | + |
| 33 | +- improved extensibility |
| 34 | +- cleaner separation of concerns |
| 35 | +- better compatibility with multiple runtimes |
| 36 | + |
| 37 | +As a result, calling core methods using `super.methodName()` is no longer reliable or supported in the same way. |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +### New Approach in Wheels 3.0+ |
| 42 | + |
| 43 | +To override a core Wheels method and still call the original implementation, you now use a **`super`-prefixed method name**. |
| 44 | + |
| 45 | +Instead of calling: |
| 46 | + |
| 47 | +``` |
| 48 | +super.findAll() |
| 49 | +``` |
| 50 | + |
| 51 | +You call: |
| 52 | + |
| 53 | +``` |
| 54 | +superFindAll() |
| 55 | +``` |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +### Example: Overriding `findAll()` |
| 60 | + |
| 61 | +```javascript |
| 62 | +component extends="Model" { |
| 63 | + |
| 64 | + function findAll() { |
| 65 | + // custom logic before calling Wheels core method |
| 66 | + |
| 67 | + return superFindAll(); |
| 68 | + } |
| 69 | + |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +This allows you to: |
| 74 | + |
| 75 | +- safely override any core Wheels method |
| 76 | +- explicitly call the original Wheels implementation |
| 77 | +- avoid framework internals or brittle inheritance behavior |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### Key Notes |
| 82 | + |
| 83 | +- The `superMethodName()` convention applies only when overriding a core Wheels method |
| 84 | +- Method names are case-insensitive, following normal CFML rules |
| 85 | +- This behavior is available in Wheels 3.x and later |
| 86 | +- No changes are required for applications that do not override core methods |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +### Migration Tip for Wheels 2.5 Applications |
| 91 | + |
| 92 | +If you are upgrading an application from Wheels 2.5 to 3.0+ and have overridden core methods: |
| 93 | + |
| 94 | +1. Search for usages of `super.methodName()` |
| 95 | +2. Replace them with `superMethodName()` |
| 96 | +3. Test overridden behavior to ensure expected results |
| 97 | + |
| 98 | +This small change restores the same extension capability that existed in Wheels 2.5, while remaining compatible with the updated framework architecture. |
0 commit comments