validation_extender = new ParentPersonalDataValidation([ 'model' => $this ]); } public function rules() { $base_rules = parent::rules(); return ArrayHelper::merge($base_rules, $this->validation_extender ? $this->validation_extender->getRules() : []); } public function getParentData() { return $this->hasOne(ParentData::class, ['personal_data_id' => 'id'])->andWhere(['archive' => false]); } public function getEmail() { return $this->parentData->email; } public function getEntrantRef() { return UserReferenceTypeManager::GetProcessedUserReferenceType($this->parentData->abiturientQuestionary->user); } public function setUserForInitialization(User $user) { $this->userForInitialization = $user; } public function afterSave($insert, $changedAttributes) { if ($insert) { $this->changeHistoryHandler ->getInsertHistoryAction() ->proceed(); } else { $this->changeHistoryHandler ->getUpdateHistoryAction() ->proceed(); } } public function getEntityIdentifier(): ?string { return Yii::t( 'abiturient/questionary/parent-personal-data', 'Идентификатор модели: `Персональные данные родителя или законного представителя`' ); } public function getAbiturientQuestionary() { if ($this->parentData === null && isset($this->userForInitialization)) { return $this->userForInitialization->getAbiturientQuestionary(); } return $this->hasOne(AbiturientQuestionary::class, ['id' => 'questionary_id']) ->viaTable('parent_data', ['personal_data_id' => 'id']); } }