Interal mechanism to add Multiples to Skill

@param Skill $model
@param mixed $data
517026
protected function doAddMultiples(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->addMultiple($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
995482
protected function doSetFeaturedTutorialId(Skill $model, $relatedId) {
		if ($model->getTutorialId() !== $relatedId) {
			$model->setTutorialId($relatedId);

			return true;
		}

		return false;
	}
1308031
protected function doSetEndPositionId(Skill $model, $relatedId) {
		if ($model->getEndPositionId() !== $relatedId) {
			$model->setEndPositionId($relatedId);

			return true;
		}

		return false;
	}
104398
protected function doUpdatePositions(Sport $model, $data) {
		// remove all relationships before
		PositionQuery::create()->filterBySport($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Position';
			} else {
				$related = PositionQuery::create()->findOneById($entry['id']);
				$model->addPosition($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]);
	}
181465
public function addParts($id, $data) {
		// find
		$model = $this->get($id);

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

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

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

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

		return NotUpdated(['model' => $model]);
	}
515706
def skill_update(self, skill_id, data, **kwargs):
        ""
        api_path = "/api/v2/skills/{skill_id}"
        api_path = api_path.format(skill_id=skill_id)
        return self.call(api_path, method="PUT", data=data, **kwargs)
116566
protected function doAddComposites(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->addSkillRelatedByCompositeId($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1057697
protected function _addNestedFieldsToExportModel(\MUtil_Model_ModelAbstract $model, array $data, array &$prefixes)
    {
        // Set labels in the main model for the submodel fields
        if ($model->getMeta('nested', false)) {
            $nestedNames = $model->getMeta('nestedNames');
            foreach($nestedNames as $nestedName) {
                $nestedModel = $model->get($nestedName, 'model');
                $nestedLabels = $nestedModel->getcolNames('label');
                foreach($nestedLabels as $colName) {
                    $label = $nestedModel->get($colName, 'label');
                    $model->set($colName, 'label', $label);
                }
                $model->remove($nestedName, 'label');
            }
        }
    }
780165
protected function _addDefaultFieldsToExportModel(\MUtil_Model_ModelAbstract $model, array $data, array &$prefixes)
    {
        if (!$model->checkJoinExists('gems__respondent2org.gr2o_id_user', 'gems__tokens.gto_id_respondent')) {
            $model->addTable('gems__respondent2org', array(
                'gems__respondent2org.gr2o_id_user' => 'gems__tokens.gto_id_respondent',
                'gems__respondent2org.gr2o_id_organization' => 'gems__tokens.gto_id_organization'), 'gr2o'
            );
        }
               
        if (!$model->checkJoinExists('gems__respondent2track.gr2t_id_respondent_track', 'gems__tokens.gto_id_respondent_track')) {
            $model->addTable('gems__respondent2track', array('gems__respondent2track.gr2t_id_respondent_track' => 'gems__tokens.gto_id_respondent_track'), 'gr2t');
        }
        if (!$model->checkJoinExists('gems__tracks.gtr_id_track', 'gems__tokens.gto_id_track')) {
            $model->addTable('gems__tracks', array('gems__tracks.gtr_id_track' => 'gems__tokens.gto_id_track'), 'gtr');
        }
        if (!$model->checkJoinExists('gems__consents.gco_description', 'gems__respondent2org.gr2o_consent')) {
            $model->addTable('gems__consents', array('gems__consents.gco_description' => 'gems__respondent2org.gr2o_consent'), 'gco');
        }

        $model->set('respondentid',        'label', $this->_('Respondent ID'), 'type', \MUtil_Model::TYPE_NUMERIC);
        $model->set('organizationid',      'label', $this->_('Organization'), 'type', \MUtil_Model::TYPE_NUMERIC,
            'multiOptions', $this->currentUser->getAllowedOrganizations()
        );
        
        // Add relation fields
        $model->set('gto_id_relation', 'label', $this->_('Relation ID'), 'type', \MUtil_Model::TYPE_NUMERIC);
        $model->set('forgroup', 'label', $this->_('Filler'), 'type', \MUtil_Model::TYPE_STRING);
        
        // Add Consent
        $model->set('consentcode',              'label', $this->_('Consent'), 'type', \MUtil_Model::TYPE_STRING);
        $model->set('resptrackid',              'label', $this->_('Respondent track ID'), 'type', \MUtil_Model::TYPE_NUMERIC);
        $model->set('gto_round_order',          'label', $this->_('Round order'));
        $model->set('gto_round_description',    'label', $this->_('Round description'));
        $model->set('gtr_track_name',           'label', $this->_('Track name'));
        $model->set('gr2t_track_info',          'label', $this->_('Track description'));

        // These are limesurvey fields, replace them with GemsTracker fields
        //$model->set('submitdate',               'label', $this->_('Submit date'));
        //$model->set('startdate',                'label', $this->_('Start date'));
        //$model->set('datestamp',                'label', $this->_('Datestamp'));
        $model->set('gto_completion_time',      'label', $this->_('Completion date'));
        $model->set('gto_start_time',           'label', $this->_('Start time'));

        $model->set('gto_valid_from',           'label', $this->_('Valid from'));
        $model->set('gto_valid_until',          'label', $this->_('Valid until'));
        $model->set('startlanguage',            'label', $this->_('Start language'));
        $model->set('lastpage',                 'label', $this->_('Last page'));

        $model->set('gto_id_token',                       'label', $this->_('Token'));
    }
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);
		}
	}
91436
public function addMultiples($id, $data) {
		// find
		$model = $this->get($id);

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

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

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

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

		return NotUpdated(['model' => $model]);
	}
43586
protected function createRelations(array &$data, \Tx_Oelib_Model $model)
    {
        foreach (array_keys($this->relations) as $key) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $this->createOneToManyRelation($data, $key, $model);
            } elseif ($this->isManyToOneRelationConfigured($key)) {
                $this->createManyToOneRelation($data, $key);
            } else {
                if ($this->isManyToManyRelationConfigured($key)) {
                    $this->createMToNRelation($data, $key, $model);
                } else {
                    $this->createCommaSeparatedRelation($data, $key, $model);
                }
            }
        }
    }
332387
public function removeMultiples($id, $data) {
		// find
		$model = $this->get($id);

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

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

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

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

		return NotUpdated(['model' => $model]);
	}
963847
public function insert(Model $m, $data)
    {
        if (!$this->mode) {
            $this->mode = 'w';
        } elseif ($this->mode == 'r') {
            throw new Exception(['Currently reading records, so writing is not possible.']);
        }

        if (!$this->handle) {
            $this->saveHeader($m);
        }

        $line = [];

        foreach ($this->header as $name) {
            $line[] = $data[$name];
        }

        $this->putLine($line);
    }
284929
protected function doRemovePictures(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->removePicture($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
312458
protected function doUpdateFeaturedTutorialSkills(Video $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByFeaturedTutorial($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->addFeaturedTutorialSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}