public function importResourcesAction($file)
 {
     $file = new \SplFileObject($file->getPathname());
     $reader = new CsvReader($file);
     $reader->setHeaderRowNumber(0);
     $data = ['resourcesTypes' => [], 'resources' => []];
     foreach ($reader as $row) {
         $resourceTypeName = ucfirst($row['resource_type']);
         $resourceName = ucfirst($row['name']);
         $maxTimeReservation = $row['max_time_reservation'];
         $description = ucfirst($row['description']);
         $localisation = ucfirst($row['localisation']);
         $quantity = $row['quantity'];
         $color = empty($row['color']) ? '#3a87ad' : $row['color'];
         $resourceType = $this->resourceTypeRepo->findOneBy(['name' => $resourceTypeName]);
         if (!$resourceType) {
             $resourceType = new ResourceType();
             $resourceType->setName($resourceTypeName);
             $this->em->persist($resourceType);
             $this->em->flush();
             $data['resourcesTypes'][] = ['id' => $resourceType->getId(), 'name' => $resourceType->getName()];
         }
         $resource = new Resource();
         $resource->setResourceType($resourceType)->setName($resourceName)->setMaxTimeReservation($maxTimeReservation)->setDescription($description)->setLocalisation($localisation)->setQuantity($quantity)->setColor($color);
         $this->em->persist($resource);
         $this->em->flush();
         $data['resources'][] = ['resourceTypeId' => $resourceType->getId(), 'resource' => ['id' => $resource->getId(), 'name' => $resourceName]];
     }
     return $data;
 }
 public function deleteEventsBoundToResourcesType(ResourceType $resourceType)
 {
     foreach ($resourceType->getResources() as $resource) {
         $this->deleteEventsBoundToResource($resource);
     }
 }