Hi,
Who can see where is my fault ?
Entity Clinic and Epidemio : No Formula
Entity Clinic have a "many2many" Epidemio and many "one2many" Epidemio.
RelationName : epidemios (many2many) and epidemiosA, epidemiosB,.... epidemiosS ... epidemiosZ
	
And log : I don't find why afterUnrelate is called ?
	
I search but not find.  In Database, the record is created in 'epidemios' table but with deleted = true.
Really strange, i have no formula, or other in these 2 entity
Thanks
					Who can see where is my fault ?
Entity Clinic and Epidemio : No Formula
Entity Clinic have a "many2many" Epidemio and many "one2many" Epidemio.
RelationName : epidemios (many2many) and epidemiosA, epidemiosB,.... epidemiosS ... epidemiosZ
PHP Code:
	
    public function afterRelate(Entity $entity, array $hookOptionData, array $relationData) : void
    {
        $this->log->error( "afterRelate". json_encode($relationData ) );
        $this->log->error( "afterRelate". json_encode($hookOptionData ) );
        
        $relationName = $relationData['relationName'] ?? null;
        $foreignEntity = $relationData['foreignEntity'] ?? null;
        
        $this->log->error('CLINIC-AFTER-RELATE=>' .$entity->getEntityType() );
        $this->log->error('CLINIC-AFTER-RELATE=>' .$foreignEntity->getEntityType() );
        $this->log->error('CLINIC-AFTER-RELATE=>' .$relationName .'=>' .$foreignEntity->getId());
        
        if ( $relationName === 'epidemios') return;
        
        $this->log->error('2-AFTER-RELATE->IN' );
        $this->em->getRDBRepository('Clinic')
                    ->getRelation($entity, 'epidemios' )
                    ->relate($foreignEntity);  
        $this->log->error('3-AFTER-RELATE-> DONE' );              
    }
    public function afterUnrelate(Entity $entity, array $hookOptionData, array $relationData): void
    {
        $this->log->error( "afterUnrelate". json_encode($relationData ) );
        $this->log->error( "afterUnrelate". json_encode($hookOptionData ) );
        
        $relationName = $relationData['relationName'] ?? null;
        $foreignEntity = $relationData['foreignEntity'] ?? null;
        $this->log->error('CLINIC-AFTER-UN-RELATE=>' .$entity->getEntityType() );
        $this->log->error('CLINIC-AFTER-UN-RELATE=>' .$foreignEntity->getEntityType() );
        $this->log->error('CLINIC-AFTER-UN-RELATE=>' .$relationName .'=>' .$foreignEntity->getId());
        
        if ( $relationName === 'epidemios') return;
        $this->log->error('2-AFTER-UN-RELATE->IN');
        $this->em->getRDBRepository('Clinic')
                ->getRelation($entity, 'epidemios')
                ->unRelate($foreignEntity);
        $this->log->error('3-AFTER-UN-RELATE->UN RELATE-> DONE' );
    } 
PHP Code:
	
[2024-08-11 12:49:42] ERROR: afterRelate{"relationName":"epidemiosE","relationData":null,"foreignEntity":{"id":"644d7d61248551f34"},"foreignId":"644d7d61248551f34"}
[2024-08-11 12:49:42] ERROR: afterRelate{"skipHooks":false}
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>Clinic
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>Epidemio
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>epidemiosE=>644d7d61248551f34
[2024-08-11 12:49:42] ERROR: 2-AFTER-RELATE->IN
[2024-08-11 12:49:42] ERROR: afterRelate{"relationName":"epidemios","relationData":null,"foreignEntity":{"id":"644d7d61248551f34"},"foreignId":"644d7d61248551f34"}
[2024-08-11 12:49:42] ERROR: afterRelate[]
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>Clinic
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>Epidemio
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-RELATE=>epidemios=>644d7d61248551f34
[2024-08-11 12:49:42] ERROR: 3-AFTER-RELATE-> DONE
// why this below is called ?
[2024-08-11 12:49:42] ERROR: afterUnrelate{"relationName":"epidemios","foreignEntity":{"id":"644d7d61248551f34"},"foreignId":"644d7d61248551f34"}
[2024-08-11 12:49:42] ERROR: afterUnrelate{"skipHooks":false}
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-UN-RELATE=>Clinic
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-UN-RELATE=>Epidemio
[2024-08-11 12:49:42] ERROR: CLINIC-AFTER-UN-RELATE=>epidemios=>644d7d61248551f34 
Really strange, i have no formula, or other in these 2 entity
Thanks

Comment