@@ -60,11 +60,6 @@ class AttributeResolver
6060
6161 private ?Config $ config ;
6262
63- /**
64- * @var AttributeRelation[]|array
65- */
66- public array $ inverseRelations = [];
67-
6863 public function __construct (string $ schemaName , ComponentSchema $ schema , JunctionSchemas $ junctions , ?Config $ config = null )
6964 {
7065 $ this ->schemaName = $ schemaName ;
@@ -280,10 +275,8 @@ protected function resolveProperty(
280275 $ relation ->asSelfReference ();
281276 }
282277 $ this ->relations [$ property ->getName ()] = $ relation ;
283- if (!$ property ->isRefPointerToSelf ()) {
284- $ this ->addInverseRelation ($ relatedClassName , $ attribute , $ property , $ fkProperty );
285- }
286278 }
279+
287280 if (!$ property ->isReference () && !$ property ->hasRefItems ()) {
288281 [$ min , $ max ] = $ property ->guessMinMax ();
289282 $ attribute ->setIsVirtual ($ property ->isVirtual ())
@@ -339,6 +332,7 @@ protected function resolveProperty(
339332 ->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
340333 return ;
341334 }
335+
342336 $ relatedClassName = $ property ->getRefClassName ();
343337 $ relatedTableName = $ property ->getRefSchema ()->resolveTableName ($ relatedClassName );
344338 if ($ this ->catchManyToMany (
@@ -519,22 +513,4 @@ public static function relationName(string $propertyName, ?string $fkColumnName)
519513 }
520514 return $ relationName ;
521515 }
522-
523- /**
524- * @throws InvalidConfigException
525- */
526- public function addInverseRelation (
527- string $ relatedClassName ,
528- Attribute $ attribute ,
529- PropertySchema $ property ,
530- PropertySchema $ fkProperty
531- ): void {
532- $ inverseRelation = Yii::createObject (
533- AttributeRelation::class,
534- [$ this ->schemaName , $ this ->tableName , $ this ->schemaName ]
535- )
536- ->asHasOne ([$ attribute ->columnName => $ fkProperty ->getName ()]);
537- $ inverseRelation ->setInverse ($ property ->getName ());
538- $ this ->inverseRelations [$ relatedClassName ][] = $ inverseRelation ;
539- }
540516}
0 commit comments