diff --git a/src/ClassCodeBundle/Command/ImportStructuresFromJsonCommand.php b/src/ClassCodeBundle/Command/ImportStructuresFromJsonCommand.php index 67eebd2e42ef0bca22e20168724b11302b1000d1..99c47c2970667ab6ef88180ecd33d17d0146715d 100644 --- a/src/ClassCodeBundle/Command/ImportStructuresFromJsonCommand.php +++ b/src/ClassCodeBundle/Command/ImportStructuresFromJsonCommand.php @@ -73,22 +73,46 @@ class ImportStructuresFromJsonCommand extends ContainerAwareCommand $type = ltrim(rtrim($data_structure['type'])); $name = ltrim(rtrim($data_structure['name'])); if($type && $name){ - - $logo = ltrim(rtrim($data_structure['logo'])); - $url = ltrim(rtrim($data_structure['url'])); - $who = ltrim(rtrim($data_structure['who'])); - $address = ltrim(rtrim($data_structure['address'])); - $location = $data_structure['location']; - if($location && is_array($location)){ - $lat = ltrim(rtrim($location['lat'])); - $long = ltrim(rtrim($location['lng'])); + if($data_structure['logo']){ + $logo = ltrim(rtrim($data_structure['logo'])); + }else{ + $logo =""; + } + if($data_structure['url']){ + $url = ltrim(rtrim($data_structure['url'])); + }else{ + $url=""; + } + if($data_structure['who']){ + $who = ltrim(rtrim($data_structure['who'])); + }else{ + $who = ""; + } + if($data_structure['address']){ + $address = ltrim(rtrim($data_structure['address'])); + }else{ + $address=""; + } + if($data_structure['location']){ + $location = $data_structure['location']; + if($location && is_array($location) && $location['lat'] && $location['lng']){ + $lat = ltrim(rtrim($location['lat'])); + $long = ltrim(rtrim($location['lng'])); + }else{ + $lat = 0; + $long = 0; + } }else{ $lat = 0; $long = 0; } - $email = ltrim(rtrim($data_structure['email'])); + if($data_structure['email']){ + $email = ltrim(rtrim($data_structure['email'])); + }else{ + $email=""; + } - $structure = $em->getRepository('ClassCodeBundle:Structure')->findOneBy(array('name' => $name,'type' => $type) ); + $structure = $em->getRepository('ClassCodeBundle:Structure')->findOneBy(array('name' => $name,'mainType' => $type) ); if(!$structure){ $structure = new Structure();