示例#1
0
 public function indexAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $entity = $em->getRepository('WeatherBundle:DataSource')->findById(2);
     $ds = new DataSource();
     $ds->setLocation(array(12, 45));
     $ds->setName('Fastov_source');
     $ds->setTemperature(24);
     $city = new City();
     $city->setName('Fastov');
     $city->setCityLocation(array(12, 74));
     $city->setPopulation(50000);
     /*$ds->addCity($city);
     
             $em->persist($ds);
     
             $em->persist($city);
             $em->flush();*/
     foreach ($entity as $a) {
         echo dump($a->getCities()->getValues());
     }
     exit;
     return $this->render('WeatherBundle:Default:index.html.twig');
 }
示例#2
0
 /**
  * Creates a form to delete a DataSource entity.
  *
  * @param DataSource $dataSource The DataSource entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(DataSource $dataSource)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('datasource_delete', array('id' => $dataSource->getId())))->setMethod('DELETE')->getForm();
 }