/** * Filter the query by a related \gossi\trixionary\model\Skill object * * @param \gossi\trixionary\model\Skill|ObjectCollection $skill The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildFunctionPhaseQuery The current query, for fluid interface */ public function filterBySkillRelatedBySkillId($skill, $comparison = null) { if ($skill instanceof \gossi\trixionary\model\Skill) { return $this->addUsingAlias(FunctionPhaseTableMap::COL_SKILL_ID, $skill->getId(), $comparison); } elseif ($skill instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(FunctionPhaseTableMap::COL_SKILL_ID, $skill->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBySkillRelatedBySkillId() only accepts arguments of type \\gossi\\trixionary\\model\\Skill or Collection'); } }
/** * Declares an association between this object and a ChildSkill object. * * @param ChildSkill $v * @return $this|\gossi\trixionary\model\SkillReference The current object (for fluent API support) * @throws PropelException */ public function setSkill(ChildSkill $v = null) { if ($v === null) { $this->setSkillId(NULL); } else { $this->setSkillId($v->getId()); } $this->aSkill = $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->addSkillReference($this); } return $this; }
/** * Exclude object from result * * @param ChildSkill $skill Object to remove from the list of results * * @return $this|ChildSkillQuery The current query, for fluid interface */ public function prune($skill = null) { if ($skill) { $this->addUsingAlias(SkillTableMap::COL_ID, $skill->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Declares an association between this object and a ChildSkill object. * * @param ChildSkill $v * @return $this|\gossi\trixionary\model\Lineage The current object (for fluent API support) * @throws PropelException */ 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; }
/** * * @param Skill $skill * @param Skill $target * @param Skill[] $pool * @param int $steps */ private function nextStep(Skill $skill, Skill $target, array $pool, $steps = 1) { $this->lineage[$steps] = $skill; if ($skill == $target) { return $steps; } $children = $skill->getChildren(); $max = 0; $next = null; $steps++; // check if target is a child $isChild = false; foreach ($children as $child) { if ($child == $target) { $isChild = true; } } // check if siblings have a connection to target if ($isChild) { $connectedSiblings = []; foreach ($children as $child) { $ids = array_keys($this->getDescendents($child)); if (in_array($target->getId(), $ids)) { $connectedSiblings[] = $child; } } // make siblings the new children if (count($connectedSiblings) > 0) { $children = $connectedSiblings; } else { return $steps; } } // filter children to get only available skills from the pool // find the one with the highest importance ... foreach ($children as $child) { if (in_array($child, $pool)) { $importance = $child->getImportance(); if ($importance > $max) { $max = $importance; $next = $child; } } } // ... and continue if ($next !== null) { return $this->nextStep($next, $target, $pool, $steps); } return $steps; }