| 1 | <?php |
||
| 22 | trait UserRelationGroupTrait |
||
| 23 | { |
||
| 24 | |||
| 25 | public $relationClass; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Attach events associated with user relation group. |
||
| 29 | */ |
||
| 30 | 10 | public function initUserRelationGroupEvents() |
|
| 34 | |||
| 35 | /** |
||
| 36 | * the event triggered before deleting group. |
||
| 37 | * I do not remove group's guid from groupsAttribute which contains the guid |
||
| 38 | * of group to be deleted. |
||
| 39 | * @param \yii\base\Event $event |
||
| 40 | */ |
||
| 41 | 2 | public function onDeleteGroup($event) |
|
| 44 | } |
||
| 45 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.