Internal update mechanism of Composites on Skill

@param Skill $model
@param mixed $data
775993
protected function doUpdateComposites(Skill $model, $data) {
		// remove all relationships before
		SkillPartQuery::create()->filterBySkillRelatedByPartId($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkillRelatedByCompositeId($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
400313
protected function doUpdateGroups(Sport $model, $data) {
		// remove all relationships before
		GroupQuery::create()->filterBySport($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Group';
			} else {
				$related = GroupQuery::create()->findOneById($entry['id']);
				$model->addGroup($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
474150
def write_skills_data(self, data=None):
        
        data = data or self.skills_data
        if skills_data_hash(data) != self.skills_data_hash:
            write_skills_data(data)
            self.skills_data_hash = skills_data_hash(data)
187763
protected function doUpdateKstrukturs(Skill $model, $data) {
		// remove all relationships before
		KstrukturQuery::create()->filterBySkill($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Kstruktur';
			} else {
				$related = KstrukturQuery::create()->findOneById($entry['id']);
				$model->addKstruktur($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
1122508
protected function doAddParents(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkillRelatedByParentId($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1363419
protected function doRemoveGroups(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Group';
			} else {
				$related = GroupQuery::create()->findOneById($entry['id']);
				$model->removeGroup($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1031589
protected function doUpdateGroups(Skill $model, $data) {
		// remove all relationships before
		SkillGroupQuery::create()->filterBySkill($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Group';
			} else {
				$related = GroupQuery::create()->findOneById($entry['id']);
				$model->addGroup($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
128053
public function addChildren($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// pass add to internal logic
		try {
			$this->doAddChildren($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(SkillEvent::PRE_CHILDREN_ADD, $model, $data);
		$this->dispatch(SkillEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(SkillEvent::POST_CHILDREN_ADD, $model, $data);
		$this->dispatch(SkillEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
903182
protected function doSetSportId(Skill $model, $relatedId) {
		if ($model->getSportId() !== $relatedId) {
			$model->setSportId($relatedId);

			return true;
		}

		return false;
	}
1274873
protected function doUpdateSkills(Object $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByObject($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
649531
protected function doUpdateSkills(Group $model, $data) {
		// remove all relationships before
		SkillGroupQuery::create()->filterByGroup($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
848871
protected function doAddPictures(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Picture';
			} else {
				$related = PictureQuery::create()->findOneById($entry['id']);
				$model->addPicture($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
733482
protected function doAddFeaturedSkills(Video $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addFeaturedSkill($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
69371
protected function doAddLineages(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Lineage';
			} else {
				$related = LineageQuery::create()->findOneById($entry['id']);
				$model->addLineage($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
440367
protected function doSetVariationOfId(Skill $model, $relatedId) {
		if ($model->getVariationOfId() !== $relatedId) {
			$model->setVariationOfId($relatedId);

			return true;
		}

		return false;
	}
929820
protected function doUpdateRootSkills(Kstruktur $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByKstrukturRoot($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addRootSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
586407
protected function doSetFunctionPhaseRootId(Skill $model, $relatedId) {
		if ($model->getFunctionPhaseId() !== $relatedId) {
			$model->setFunctionPhaseId($relatedId);

			return true;
		}

		return false;
	}