public function onUpdateRelation($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if ($sender->relationType == static::$relationMutual) {
            $opposite = static::buildOppositeRelation($sender);
            $opposite->off(static::EVENT_AFTER_UPDATE, [$opposite, 'onUpdateRelation']);
            if (!$opposite->save()) {
                $opposite->recordWarnings();
                throw new IntegrityException('Reverse relation update failed.');
            }
            $opposite->on(static::EVENT_AFTER_UPDATE, [$opposite, 'onUpdateRelation']);
        }
    }
public function onUpdateRelation($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if ($sender->relationType == static::$relationMutual) {
            $opposite = static::buildOppositeRelation($sender);
            $opposite->off(static::EVENT_AFTER_UPDATE, [$opposite, 'onUpdateRelation']);
            if (!$opposite->save()) {
                $opposite->recordWarnings();
                throw new IntegrityException('Reverse relation update failed.');
            }
            $opposite->on(static::EVENT_AFTER_UPDATE, [$opposite, 'onUpdateRelation']);
        }
    }
public function onUpdateRelation ( $ event ) { $ sender = $ event -> sender ; /* @var $sender static */ if ( $ sender -> relationType == static :: $ relationMutual ) { $ opposite = static :: buildOppositeRelation ( $ sender ) ; $ opposite -> off ( static :: EVENT_AFTER_UPDATE , [ $ opposite , 'onUpdateRelation' ] ) ; if ( ! $ opposite -> save ( ) ) { $ opposite -> recordWarnings ( ) ; throw new IntegrityException ( 'Reverse relation update failed.' ) ; } $ opposite -> on ( static :: EVENT_AFTER_UPDATE , [ $ opposite , 'onUpdateRelation' ] ) ; } }
The event triggered after update relation.
The opposite relation should be updated without triggering events
simultaneously after existed relation removed.
@param ModelEvent $event
@throw IntegrityException throw if update failed.
The event triggered after update relation . The opposite relation should be updated without triggering events simultaneously after existed relation removed .