/** * {@inheritDoc} */ public function removeGene(Gene $gene, $recurse = true) { $this->genes->removeElement($gene); if ($recurse === true) { $gene->removeExon($this, false); } }
/** * Set groups * * @param SimpleXMLElement $xml * @return void */ private function setGroups(\SimpleXMLElement $xml) { $this->groups = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($xml->children() as $groupXml) { $this->groups->add(Group::createFromXml($groupXml)); } }
/** * {@inheritDoc} */ public function removemRNA(mRNA $mRNA, $recurse = true) { $this->mRNAs->removeElement($mRNA); if ($recurse === true) { $mRNA->removeUTR3($mRNA, false); } }
/** * Set remote content * * @param SimpleXMLElement $xml * @return void */ private function setRemoteContent(\SimpleXMLElement $xml) { $this->remoteContent = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($xml->children() as $remoteContentXml) { $this->remoteContent->add(RemoteContent::createFromXml($remoteContentXml)); } }
/** * Remove tag * * @param VIB\Bundle\BioBundle\Entity\DNA\Abstracts\FeatureTag $tag * @param boolean $recurse */ public function removeTag(FeatureTag $tag, $recurse = true) { $this->tags->removeElement($tag); if ($recurse === true) { $tag->setFeature(null, false); } }
/** * Remove intron * * @param VIB\Bundle\BioBundle\Entity\DNA\Feature\Gene\Intron $intron * @param boolean $recurse */ public function removeIntron(Intron $intron, $recurse = true) { $this->introns->removeElement($intron); if ($recurse === true) { $intron->removeGene($this, false); } }
/** * Set subjects * * @param SimpleXMLElement $xml * @return void */ protected function setSubjects(\SimpleXMLElement $xml) { $this->subjects = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($xml->subject as $subjectXml) { $this->subjects->add(Subject::createFromXml($subjectXml)); } }
/** * Remove feature * * @param VIB\Bundle\BioBundle\Entity\DNA\Abstracts\Feature $feature * @param boolean $recurse */ public function removeFeature(Feature $feature, $recurse = true) { $this->features->removeElement($feature); if ($recurse === true) { $feature->setSequence(null, false); } }
/** * Set catalog refs * * @param SimpleXMLElement $xml * @return void */ public function setCatalogRefs(\SimpleXMLElement $xml) { $this->catalogRefs = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($xml->catalogRef as $catalogRefXml) { $this->catalogRefs->add(new CatalogRef($catalogRefXml['href'])); } }
/** * Set refs * * @param SimpleXMLElement $xml * @return void */ public function setRefs($xml) { $this->refs = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($xml->children() as $refXml) { if ($refXml->getName() === 'groupRef') { $this->refs->add(new GroupRef($refXml['idref'])); } else { if ($refXml->getName() === 'itemRef') { $this->refs->add(ItemRef::createFromXml($refXml)); } else { throw new \InvalidArgumentException("Expected group or item ref, got '{$refXml->getName()}'"); } } } }
/** * Add item for this participant * * @param Doctrine\Common\Collections\Collection $items * @return Participant */ public function addItems(Item $item) { if (!$this->items->contains($item)) { $this->items->add($item); } return $this; }
/** * @param string $value * @param Doctrine\Common\Collections\Collection $collection */ public function reverseTransform($value, $collection) { if (strlen(trim($value)) == 0) { // don't check for collection count, a straight clear doesnt initialize the collection $collection->clear(); return $collection; } $className = $this->getOption('className'); $values = explode($this->getOption('separator'), $value); if ($this->getOption('trim') === true) { $values = array_map('trim', $values); } /* @var $em Doctrine\ORM\EntityManager */ $em = $this->getOption('em'); $reflField = $em->getClassMetadata($className)->getReflectionProperty($this->getOption('fieldName')); // 1. removing elements that are not yet present anymore foreach ($collection as $object) { $uniqueIdent = $reflField->getValue($object); $key = \array_search($uniqueIdent, $values); if ($key === false) { $collection->removeElement($object); } else { // found in the collection, no need to do anything with it so remove it unset($values[$key]); } } // 2. add elements that are known to the EntityManager but newly connected, query them from the repository if (count($values)) { $dql = "SELECT o FROM " . $className . " o WHERE o." . $this->getOption('fieldName') . " IN ("; $query = $em->createQuery(); $needles = array(); $i = 0; foreach ($values as $val) { $query->setParameter(++$i, $val); $needles[] = "?" . $i; } $dql .= implode(",", $needles) . ")"; $query->setDql($dql); $newElements = $query->getResult(); foreach ($newElements as $object) { $collection->add($object); $uniqueIdent = $reflField->getValue($object); $key = \array_search($uniqueIdent, $values); unset($values[$key]); } } // 3. new elements that are not in the repository have to be created and persisted then attached: if (count($values)) { $callback = $this->getOption('createInstanceCallback'); if (!$callback || !\is_callable($callback)) { throw new TransformationFailedException("Cannot transform list of identifiers, because a new " . "element was detected and it is unknown how to create an instance of this element."); } foreach ($values as $newValue) { $newInstance = \call_user_func($callback, $newValue); if (!$newInstance instanceof $className) { throw new TransformationFailedException("Error while trying to create a new instance for " . "the identifier '" . $newValue . "'. No new instance was created."); } $collection->add($newInstance); $em->persist($newInstance); } } return $collection; }
/** * Remove detailIndicateurs * * @param \AppBundle\Entity\DetailIndicateur $detailIndicateurs */ public function removeDetailIndicateur(\AppBundle\Entity\DetailIndicateur $detailIndicateurs) { $this->detailIndicateurs->removeElement($detailIndicateurs); }
/** * Get view. * * @return object */ public function getView() { try { $view = new ArticleView(array('number' => $this->number, 'language' => $this->language->getCode(), 'languageId' => $this->language->getId(), 'title' => $this->name, 'updated' => $this->updated, 'published' => $this->published, 'indexed' => $this->indexed, 'onFrontPage' => $this->onFrontPage, 'onSection' => $this->onSection, 'type' => $this->type, 'webcode' => $this->getWebcode(), 'publication_number' => $this->publication ? $this->publication->getId() : null, 'issue_number' => $this->issue ? $this->issue->getNumber() : null, 'section_number' => $this->section ? $this->section->getNumber() : null, 'keywords' => array_filter(explode(',', $this->keywords)))); } catch (EntityNotFoundException $e) { return new ArticleView(); } $view->authors = $this->authors->map(function ($author) { return $author->getView()->name; })->toArray(); $view->topics = $this->topics->map(function ($topic) { return $topic->getView()->name; })->toArray(); $this->addFields($view); return $view; }
/** * Add ban of a champion for this game * * @param Doctrine\Common\Collections\Collection $bans * @return Game */ public function addBans(Champion $ban) { if (!$this->bans->contains($ban)) { $this->bans->add($ban); } return $this; }
/** * (non-PHPdoc) * @see \Rizza\CalendarBundle\Model\CalendarInterface::removeEvent() */ public function removeEvent(EventInterface $event) { if ($this->events->contains($event)) { $this->events->removeElement($event); } }
/** * Is polycistronic * * @return boolean */ public function isPolycistronic() { return $this->genes->count() > 1 ? true : false; }
/** * Remove users * * @param Nmpolo\RestBundle\Entity\User $users */ public function removeUser(\Nmpolo\RestBundle\Entity\User $users) { $this->users->removeElement($users); }