Feature #6712
Implement mixin support
Status: | Accepted | Start date: | ||
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Robert Lemke | % Done: | 0% |
|
Category: | AOP | |||
Target version: | - | Estimated time: | 18.00 hours | |
PHP Version: | Complexity: | |||
Has patch: |
Description
With the current implementation of introductions / intertype declarations it is -like in most other AOP frameworks - only possible to introduce interfaces. However, it would be very handy being able to introduce properties along with some methods.
A very common use case would be introducing a new property along with a getter and a setter method:
/** * @entity * @scope prototype */ class BonusCustomerDetails { /** * @var string */ protected $bonusCode; public function getBonusCode() { return $this->bonusCode; } public function setBonusCode($bonusCode) { $this->bonusCode = $bonuscode; } }
This property + methods could be introduced into the Customer class by using a new annotation:
/** * @mixin F3\Bar\Domain\Model\Customer * @entity * @scope prototype */ class BonusCustomerDetails { /** * @var string */ protected $bonusCode; public function getBonusCode() { return $this->bonusCode; } public function setBonusCode($bonusCode) { $this->bonusCode = $bonuscode; } }
The @mixin annotation would implicitly generate a new aspect which implements around advices for the getter and setter method. Additionally a new property will be introduced into the Customer class which refers to the BonusCustomerDetails. The implementation of the around advice now simply refers to the original methods within the BonusCustomerDetails.
History
#1 Updated by Robert Lemke over 5 years ago
- Start date deleted (
2010-03-05) - Estimated time set to 18.00
don't forget that the class schema builder must be able to detect the introduced property
#2 Updated by Robert Lemke over 5 years ago
- Target version changed from 1.0 alpha 8 to 1.0 alpha 9
#3 Updated by Robert Lemke about 5 years ago
- Target version deleted (
1.0 alpha 9)