コード例 #1
0
 /**
  * Removes a link between an activity and an ability or a competency.
  *
  * @param Activity $activity
  * @param Ability|Competency $target
  * @throws \InvalidArgumentException if the target isn't an instance of Ability or Competency
  * @throws \LogicException if the link doesn't exists
  */
 public function removeLink(Activity $activity, $target)
 {
     if (!$target instanceof Ability && !$target instanceof Competency) {
         throw new \InvalidArgumentException('Second argument must be a Competency or an Ability instance');
     }
     if (!$target->isLinkedToActivity($activity)) {
         throw new \LogicException("There's no link between activity {$activity->getId()} and target {$target->getId()}");
     }
     $target->removeActivity($activity);
     $this->om->flush();
 }