/** * @param string $colors * @return void */ public function indexAction($colors = null) { $oldColors = new \Doctrine\Common\Collections\ArrayCollection($this->colorRepository->findAll()->toArray()); $colorNames = ""; if ($colors === null) { foreach ($oldColors as $color) { if (!empty($colorNames)) { $colorNames .= "\n"; } $colorNames .= $color->getName(); } } else { $colorNames = $colors; foreach (explode("\n", $colors) as $colorName) { $colorName = trim($colorName); if (empty($colorName)) { continue; } $color = $this->colorRepository->findOneByName($colorName); if (empty($color)) { $color = new Color($colorName); $this->colorRepository->add($color); } if ($oldColors) { $oldColors->removeElement($color); } } if ($oldColors) { foreach ($oldColors as $color) { $this->colorRepository->remove($color); } } } $this->view->assign('colors', $colorNames); }
public function removeParticipantMeta(\Application\Entity\ParticipantMetaEntity $participantMeta) { $participantMeta->setParticipant(null); $this->participantMetas->removeElement($participantMeta); return $this; }
/** * Remove article_languages * * @param \CMS\Bundle\AdminBundle\Entity\ArticleLanguage $articleLanguages */ public function removeArticleLanguage(\CMS\Bundle\AdminBundle\Entity\ArticleLanguage $articleLanguages) { $this->article_languages->removeElement($articleLanguages); }
public function removePhoto(Photo $photo) { $this->photos->removeElement($photo); $this->sortPhotos(); }
public function removeEntryMeta(\Application\Entity\EntryMetaEntity $entryMeta) { $entryMeta->setEntry(null); $this->entryMetas->removeElement($entryMeta); return $this; }
/** * Edits an existing Tag entity. * * @Route("/{id}", name="tag_update") * @Method("PUT") * @Template("PaxyknoxNewsBundle:Tag:edit.html.twig") */ public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('PaxyknoxNewsBundle:Tag')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Tag entity.'); } // before Tag change // get list of all Articles with this Tag // $articles = $entity->getArticles(); $oldArticlesIdsList = new \Doctrine\Common\Collections\ArrayCollection(); foreach ($articles as $article) { $oldArticlesIdsList[] = $article->getId(); } $editForm = $this->createEditForm($entity); $editForm->handleRequest($request); if ($editForm->isValid()) { try { // Tag entity $em->flush(); // For each selected Article on edit form get its id // // Check if it is in $oldArticlesIdsList // - true remove it from the list // - false find Article and set Tag on it // // Articles that will remain on the list no longer need Tag set on it // $data = $request->request->all(); foreach ($data as $dataParameter => $dataParameterValue) { if (isset($dataParameterValue["articles"])) { foreach ($dataParameterValue["articles"] as $articleIdString) { $articleId = (int) $articleIdString; if ($oldArticlesIdsList->contains($articleId)) { $oldArticlesIdsList->removeElement($articleId); } else { $article = $em->getRepository('PaxyknoxNewsBundle:Article')->find($articleId); $article->addTag($entity); } } } } if (!$oldArticlesIdsList->isEmpty()) { foreach ($oldArticlesIdsList as $articleId) { $article = $em->getRepository('PaxyknoxNewsBundle:Article')->find($articleId); $article->removeTag($entity); $oldArticlesIdsList->removeElement($articleId); } } // Article Entity $em->flush(); $flashMessage = $this->get('translator')->trans('flash.tag.update_success', array('%s%' => $entity->getName())); $this->get('session')->getFlashBag()->add('success', $flashMessage); } catch (\Doctrine\DBAL\DBALException $e) { $flashMessage = $this->get('translator')->trans('flash.tag.update_warning'); $this->get('session')->getFlashBag()->add('warning', $flashMessage); return $this->redirect($this->generateUrl('tag_edit', array('id' => $id))); } return $this->redirect($this->generateUrl('tag_show', array('id' => $id))); } return array('entity' => $entity, 'edit_form' => $editForm->createView()); }
public function removeVoteMeta(\Application\Entity\VoteMetaEntity $voteMeta) { $voteMeta->setVote(null); $this->voteMetas->removeElement($voteMeta); return $this; }
/** * Remove um documento do tipo nota da importação * * @param \Contribuinte\Nota */ public function removeNota(\Contribuinte\Nota $oNota) { $this->notas->removeElement($oNota); }
/** * Remove page_languages * * @param \CMS\Bundle\AdminBundle\Entity\PageLanguage $pageLanguages */ public function removePageLanguage(\CMS\Bundle\AdminBundle\Entity\PageLanguage $pageLanguages) { $this->page_languages->removeElement($pageLanguages); }