private function buildPubEntity($citEntity, &$em)
 {
     $pubEntity = new Publication();
     $pubEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
     $pubEntity->setDisplayName($citEntity->getTitle());
     $pubEntity->setPublicationType($em->getRepository("AppBundle:PublicationType")->findOneBy(array("displayName" => "Article")));
     $em->persist($pubEntity);
     return $pubEntity;
 }
 private function addPub($pubVals, &$em)
 {
     print "\n    add pub ->" . $pubVals[0];
     $pubEntity = new Publication();
     $pubEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
     $pubEntity->setDisplayName($pubVals[0]);
     $pubEntity->setDescription($pubVals[1]);
     $pubEntity->setPublicationType($em->getRepository("AppBundle:PublicationType")->findOneBy(array("displayName" => $pubVals[2])));
     $em->persist($pubEntity);
     return $pubEntity;
 }
Beispiel #3
0
 public function load(ObjectManager $manager)
 {
     for ($i = 0; $i < 3; $i++) {
         $new = new Publication();
         $new->setSlug('new-' . $i);
         $new->setTitle('Мизулина предлагает оградить российских детей от пагубного влияния онлайн видеоигр');
         $new->setBody('Мерило нравственности и блюститель духовных скреп российских граждан, Елена Борисовна Мизулина
                     возвращается на законодательное поле боя с новой инициативой — оградить российских детей от
                     «плохих» онлайн видеоигр');
         $new->setCreated(new \DateTime('20.03.1016'));
         $manager->persist($new);
         $manager->flush();
     }
 }
 /**
  * Creates a form to delete a Publication entity.
  *
  * @param Publication $publication The Publication entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Publication $publication)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('publication_delete', array('id' => $publication->getId())))->setMethod('DELETE')->getForm();
 }
 /**
  * Ajax action to create a new Publication entity.
  *
  * @Route("/post", name="app_publication_post")
  * @Method("POST")
  */
 public function postAction(Request $request)
 {
     $requestContent = $request->getContent();
     $pushedData = json_decode($requestContent);
     $entityData = $pushedData->entityData;
     $refData = [];
     $returnData = [];
     foreach ($entityData as $data) {
         $refId = $data->tempId;
         $name = $data->pubTitle;
         $publisher = $data->publisher;
         $pubType = $data->pubType;
         $entity = new Publication();
         $entity->setName($name);
         // $entity->setLastName($lastName);
         // $entity->setFullName($fullName);
         $refData[$refId] = $entity;
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
     }
     $em->flush();
     foreach ($refData as $refId => $entity) {
         $returnData[$refId] = $entity->getId();
     }
     $response = new JsonResponse();
     $response->setData(array('publication' => $returnData));
     return $response;
 }