1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
   |  
<?php
$request = Request::createFromGlobals();
  $em = $this->getDoctrine()->getEntityManager();
  $platform = $request->query->get('platform');
  $id=$request->query->get('id');
 
  $userManager = $this->container->get('fos_user.user_manager');
  $user = $userManager->findUserBy(array('id' =>$id));
  if($user)
  { 
  $teams=$user->getTeams();
 
  foreach($teams as $teams)
   { 
	$builds=$teams->getBuilds();
 
         foreach($builds as $builds)
         {     
 
 foreach($builds->getApplication() as $applications)                
 {
 
 
 //ici je veux faire un test sur $applications($builds->getApplication()) en fonction de la platform 
//et si je fais par exemple $applications->findByPlatform($platform)j'obtient l'erreur Call to undefined method //Proxies
 
//je cherche à modifier la fonction ci dessous et je n'arrive pas
$applications = $em->getRepository('BetappliApplicationBundle:Application')->findByPlatform($platform);
 
if(!$applications) {
 
  $xml = $serializer->serialize(array('error' => $error), 'xml');
  return new Response($xml);
  }
 
   foreach ($applications as $application) { 
 
  foreach ($application->getBuilds() as $build) {
   $Date=$build->getUploadDate();
   $dt= new DateTimeToArrayTransformer();
   $d=$dt->transform($Date);
   $id=$build->getId();
   $dir =$build->getUploadRootDir();
   if($platform=='Android'){
   $fileName=$build->id.'.apk';
     }
     else
     {
     $fileName=$build->id.'.ipa';
     } 
 
  $xml[]=array('application'=>array_merge(array('@id'=>$application->getId(),'name'=>$application->getapplicationName(),'icon'=>$application->getAbsolutePath_icon()),array('build'=>(array('@id'=>$build->getId(),'name'=>$build->getbuildName(),'upload' => $build->getUploadRootDir_build($fileName),
      'uploaddate' => $d)))));  
 
 
 
  }
  }
 
  $xml = $serializer->serialize(array('application'=>$xml), 'xml');
 
  return new Response($xml);
 
 
 }
 
 }
 
 }
 
 }
 
 else 
 {
 $xml = $serializer->serialize(array('error' => $error2), 'xml');
  return new Response($xml);
 }
   }
?> | 
Partager