File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ public function __construct(){
1717
1818 public function make ( $ relation ): RelationHandler
1919 {
20+ // at first search in registered handlers, user can register his own handlers
21+ $ relationClass = get_class ($ relation );
22+
23+ if ($ this ->handlers ->has ($ relationClass ))
24+ {
25+ return $ this ->handlers ->get ($ relationClass );
26+ }
27+
28+ // then try to check is relation has instance of base relations
2029 $ handler = $ this ->handlers ->first (function (RelationHandler $ handler ) use ($ relation ){
2130 $ handlerRelation = $ handler ->relation ();
2231 return $ relation instanceof $ handlerRelation ;
@@ -27,6 +36,7 @@ public function make( $relation ): RelationHandler
2736 return $ handler ;
2837 }
2938
39+ // oops, not registered relation
3040 throw new DomainException (sprintf ('RelationHandler for relation: %s is not registered ' , $ relation ));
3141 }
3242
You can’t perform that action at this time.
0 commit comments