private static function updateProjectMembership($taskid, $projects) { // projects: task should belong to these $memberOf = Task::getMemberOfProjects($taskid); // a member of before we update foreach ($projects as $project) { if (!in_array($project, $memberOf)) { // not a member yet Project::addTask($taskid, $project); Project::updateCount($project); } } foreach ($memberOf as $memberProj) { if (!in_array($memberProj, $projects)) { // a member, but should not be anymore Project::removeTask($taskid, $memberProj); Project::updateCount($memberProj); } } }
/** * Declares an association between this object and a Project object. * * @param Project $v * @return Task The current object (for fluent API support) * @throws PropelException */ public function setProject(Project $v = null) { if ($v === null) { $this->setProjectId(NULL); } else { $this->setProjectId($v->getId()); } $this->aProject = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Project object, it will not be re-added. if ($v !== null) { $v->addTask($this); } return $this; }