Associate a ChildSkill to this object
through the kk_trixionary_skill_dependency cross reference table.

@param ChildSkill $skillRelatedByDependencyId
@return ChildSkill The current object (for fluent API support)
423010
public function addSkillRelatedByDependencyId(ChildSkill $skillRelatedByDependencyId)
    {
        if ($this->collSkillsRelatedByDependencyId === null) {
            $this->initSkillsRelatedByDependencyId();
        }

        if (!$this->getSkillsRelatedByDependencyId()->contains($skillRelatedByDependencyId)) {
            // only add it if the **same** object is not already associated
            $this->collSkillsRelatedByDependencyId->push($skillRelatedByDependencyId);
            $this->doAddSkillRelatedByDependencyId($skillRelatedByDependencyId);
        }

        return $this;
    }
704990
protected function doSetFeaturedPictureId(Skill $model, $relatedId) {
		if ($model->getPictureId() !== $relatedId) {
			$model->setPictureId($relatedId);

			return true;
		}

		return false;
	}
1360361
public function setAncestor(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setAncestorId(NULL);
        } else {
            $this->setAncestorId($v->getId());
        }

        $this->aAncestor = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addLineageRelatedByAncestorId($this);
        }


        return $this;
    }
491391
public function getRelatedResourceReference(
        ResourceSet $sourceResourceSet,
        $sourceEntityInstance,
        ResourceSet $targetResourceSet,
        ResourceProperty $targetProperty
    ) {
        $entityClassName = $targetResourceSet->getResourceType()->getInstanceType()->name;
        $entityName = $this->getEntityName($entityClassName);
        $fieldName = $this->getTableName($entityName) . '_id';

        return $this->getResource($targetResourceSet, null, [
            'id' => $sourceEntityInstance->$fieldName
        ]);
    }
1259001
protected function doSetObjectId(Skill $model, $relatedId) {
		if ($model->getObjectId() !== $relatedId) {
			$model->setObjectId($relatedId);

			return true;
		}

		return false;
	}
560591
public function removeReference(ChildReference $reference)
    {
        if ($this->getReferences()->contains($reference)) { $skillReference = new ChildSkillReference();

            $skillReference->setReference($reference);
            if ($reference->isSkillsLoaded()) {
                //remove the back reference if available
                $reference->getSkills()->removeObject($this);
            }

            $skillReference->setSkill($this);
            $this->removeSkillReference(clone $skillReference);
            $skillReference->clear();

            $this->collReferences->remove($this->collReferences->search($reference));

            if (null === $this->referencesScheduledForDeletion) {
                $this->referencesScheduledForDeletion = clone $this->collReferences;
                $this->referencesScheduledForDeletion->clear();
            }

            $this->referencesScheduledForDeletion->push($reference);
        }


        return $this;
    }
763740
public function menuLinkDependency($title, $link, $translations, $destBid, $weight = 0, $menu = 'main') {
    $menu_link_content = $this->entityManager->getStorage('menu_link_content')->create([
      'title' => $title,
      'link' => ['uri' => 'internal:/node/' . $destBid[0]],
      'menu_name' => (!empty($translations)) ? $menu . '-fr' : $menu,
      'langcode' => (!empty($translations)) ? 'fr' : 'en',
      'parent' => $link,
      'weight' => $weight,
    ]);
    $menu_link_content->save();
    $this->database->update('menu_link_content_data')
      ->fields(['link__uri' => 'entity:node/' . $destBid[0]])
      ->condition('id', $menu_link_content->id())
      ->execute();
    return $menu_link_content;
  }
634737
public function assignChild ($relationIdentifier, $id, $childId)
		{
			$relation = $this->getRelation($relationIdentifier);

			if (!$relation) {
				throw new RelationException('Invalid relation `' . $relationIdentifier);
			}

			if ($relation instanceof OneToMany) {
				$this->database->createQuery()
					->update()
					->table($relation->getRelatedTable())
					->set(
						array(
							$relation->getRelatedKey() => $id,
						)
					)
					->whereEqual($relation->getKey(), $childId)
					->execute();
			} else if ($relation instanceof ManyToMany) {
				if (! $this->getChild($relationIdentifier, $id, $childId)) {
					$this->database->createQuery()
						->insert()
						->into($relation->getRelationalTable())
						->set(
							array(
								$relation->getKey()         => $id,
								$relation->getRelatedKey()  => $childId,
							)
						)
						->execute();
				}
			} else {
				throw new RelationException('Invalid relation type `' . gettype($relation) . '`');
			}
		}
389629
protected function doSetStartPositionId(Skill $model, $relatedId) {
		if ($model->getStartPositionId() !== $relatedId) {
			$model->setStartPositionId($relatedId);

			return true;
		}

		return false;
	}
1047263
protected function doUpdateParts(Skill $model, $data) {
		// remove all relationships before
		SkillPartQuery::create()->filterBySkillRelatedByCompositeId($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->addSkillRelatedByPartId($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
557759
public function removeSkillRelatedByParentId(ChildSkill $skillRelatedByParentId)
    {
        if ($this->getSkillsRelatedByParentId()->contains($skillRelatedByParentId)) { $skillDependency = new ChildSkillDependency();

            $skillDependency->setSkillRelatedByParentId($skillRelatedByParentId);
            if ($skillRelatedByParentId->isSkillRelatedByDependencyIdsLoaded()) {
                //remove the back reference if available
                $skillRelatedByParentId->getSkillRelatedByDependencyIds()->removeObject($this);
            }

            $skillDependency->setSkillRelatedByDependencyId($this);
            $this->removeChild(clone $skillDependency);
            $skillDependency->clear();

            $this->collSkillsRelatedByParentId->remove($this->collSkillsRelatedByParentId->search($skillRelatedByParentId));

            if (null === $this->skillsRelatedByParentIdScheduledForDeletion) {
                $this->skillsRelatedByParentIdScheduledForDeletion = clone $this->collSkillsRelatedByParentId;
                $this->skillsRelatedByParentIdScheduledForDeletion->clear();
            }

            $this->skillsRelatedByParentIdScheduledForDeletion->push($skillRelatedByParentId);
        }


        return $this;
    }
342291
public static function get_related_competencies($competencyid) {
        global $DB;

        $fields = competency::get_sql_fields('c', 'c_');
        $sql = "(SELECT $fields, " . $DB->sql_concat('rc.relatedcompetencyid', "'_'", 'rc.competencyid') . " AS rid
                   FROM {" . self::TABLE . "} rc
                   JOIN {" . competency::TABLE . "} c
                     ON c.id = rc.relatedcompetencyid
                  WHERE rc.competencyid = :cid)
              UNION ALL
                (SELECT $fields, " . $DB->sql_concat('rc.competencyid', "'_'", 'rc.relatedcompetencyid') . " AS rid
                   FROM {" . self::TABLE . "} rc
                   JOIN {" . competency::TABLE . "} c
                     ON c.id = rc.competencyid
                  WHERE rc.relatedcompetencyid = :cid2)
               ORDER BY c_path ASC, c_sortorder ASC";

        $competencies = array();
        $records = $DB->get_recordset_sql($sql, array('cid' => $competencyid, 'cid2' => $competencyid));
        foreach ($records as $record) {
            unset($record->rid);
            $competencies[$record->c_id] = new competency(null, competency::extract_record($record, 'c_'));
        }
        $records->close();

        return $competencies;
    }
1237726
protected function doUpdateMultiples(Skill $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByMultipleOf($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->addMultiple($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
710191
public static function getInstance($dependencyName, array $loadedDependencies)
    {
        $k = $dependencyName . '_' . implode('_', $loadedDependencies);
        if (!isset(self::$_instances[$k])) {
            self::$_instances[$k] = new self(Kwf_Assets_Package_Default::getDefaultProviderList(), $dependencyName, $loadedDependencies);
        }
        return self::$_instances[$k];
    }
766562
public function setSkillRelatedByCompositeId(ChildSkill $v = null)
    {
        if ($v === null) {
            $this->setCompositeId(NULL);
        } else {
            $this->setCompositeId($v->getId());
        }

        $this->aSkillRelatedByCompositeId = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildSkill object, it will not be re-added.
        if ($v !== null) {
            $v->addComposite($this);
        }


        return $this;
    }
578412
public function addVariation(ChildSkill $l)
    {
        if ($this->collVariations === null) {
            $this->initVariations();
            $this->collVariationsPartial = true;
        }

        if (!$this->collVariations->contains($l)) {
            $this->doAddVariation($l);
        }

        return $this;
    }
586407
protected function doSetFunctionPhaseRootId(Skill $model, $relatedId) {
		if ($model->getFunctionPhaseId() !== $relatedId) {
			$model->setFunctionPhaseId($relatedId);

			return true;
		}

		return false;
	}