Skip to content

Commit 2d36373

Browse files
Copilotjbtronics
andcommitted
Add trait dependency documentation and architecture diagrams
Co-authored-by: jbtronics <5410681+jbtronics@users.noreply.github.com>
1 parent 30537fc commit 2d36373

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

ENTITY_REFACTORING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,48 @@
44

55
This refactoring decomposes the deep entity inheritance hierarchy into a more flexible trait-based architecture. This provides better code reusability, composition, and maintainability.
66

7+
## Architecture Diagram
8+
9+
### Before (Deep Inheritance):
10+
```
11+
AbstractDBElement (ID logic)
12+
└─ AbstractNamedDBElement (name + timestamps)
13+
└─ AttachmentContainingDBElement (attachments)
14+
└─ AbstractStructuralDBElement (tree/hierarchy + parameters)
15+
├─ AbstractPartsContainingDBElement
16+
│ ├─ Category
17+
│ ├─ Footprint
18+
│ ├─ StorageLocation
19+
│ └─ AbstractCompany (company fields)
20+
│ ├─ Manufacturer
21+
│ └─ Supplier
22+
```
23+
24+
### After (Trait Composition):
25+
```
26+
Traits: Interfaces:
27+
- DBElementTrait - DBElementInterface
28+
- NamedElementTrait - NamedElementInterface
29+
- TimestampTrait - TimeStampableInterface
30+
- AttachmentsTrait - HasAttachmentsInterface
31+
- MasterAttachmentTrait - HasMasterAttachmentInterface
32+
- StructuralElementTrait - StructuralElementInterface
33+
- ParametersTrait - HasParametersInterface
34+
- CompanyTrait - CompanyInterface
35+
36+
Class Hierarchy (now uses traits):
37+
AbstractDBElement (uses DBElementTrait, implements DBElementInterface)
38+
└─ AbstractNamedDBElement (uses NamedElementTrait + TimestampTrait)
39+
└─ AttachmentContainingDBElement (uses AttachmentsTrait + MasterAttachmentTrait)
40+
└─ AbstractStructuralDBElement (uses StructuralElementTrait + ParametersTrait)
41+
├─ AbstractPartsContainingDBElement
42+
│ ├─ Category (gets all traits via inheritance)
43+
│ ├─ Footprint (gets all traits via inheritance)
44+
│ └─ AbstractCompany (uses CompanyTrait)
45+
│ ├─ Manufacturer
46+
│ └─ Supplier
47+
```
48+
749
## Changes Made
850

951
### New Traits Created

src/Entity/Base/AttachmentsTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
/**
3131
* Trait providing attachments functionality.
32+
*
33+
* Requirements:
34+
* - Class using this trait should have $id property (e.g., via DBElementTrait)
35+
* - Class may optionally have $master_picture_attachment property (via MasterAttachmentTrait)
36+
* - Class should implement HasAttachmentsInterface
3237
*/
3338
trait AttachmentsTrait
3439
{

src/Entity/Base/StructuralElementTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
/**
3636
* Trait for structural/hierarchical elements forming a tree structure.
37+
*
38+
* Requirements:
39+
* - Class using this trait must have getName() method (e.g., via NamedElementTrait)
40+
* - Class using this trait must have getID() method (e.g., via DBElementTrait)
41+
* - Class should implement StructuralElementInterface
3742
*/
3843
trait StructuralElementTrait
3944
{

0 commit comments

Comments
 (0)