Feature #6712

Implement mixin support

Added by Robert Lemke over 11 years ago. Updated over 9 years ago.

Status:
Accepted
Priority:
Should have
Assignee:
Category:
AOP
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
18.00 h
PHP Version:
Has patch:
Complexity:

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.

#1

Updated by Robert Lemke over 11 years ago

  • Start date deleted (2010-03-05)
  • Estimated time set to 18.00 h

don't forget that the class schema builder must be able to detect the introduced property

#2

Updated by Robert Lemke over 11 years ago

  • Target version changed from 1.0 alpha 8 to 1.0 alpha 9
#3

Updated by Robert Lemke about 11 years ago

  • Target version deleted (1.0 alpha 9)

Also available in: Atom PDF