private function insertData(Api $api, Request $request)
 {
     //get this data here (before getDataForApi()) because $em->clear() make bad
     $storeColumns = $api->getStore()->getColumns();
     $appId = $api->getApp()->getAppId();
     $data = $request->request->all();
     $executed = 0;
     if (empty($data)) {
         throw new MissingDataException('No data given');
     }
     $dataO = new Data();
     $dataO->setStore($api->getStore());
     $dataO->setColumns(array_keys($data));
     $dataO->setData($data);
     $this->getDoctrine()->getManager()->persist($dataO);
     $this->getDoctrine()->getManager()->flush();
     $store = $api->getStore();
     $em = $this->getDoctrine()->getManager();
     //Add any new columns to the store
     $newColumns = array_diff(array_keys($data), $storeColumns);
     if (count($newColumns)) {
         $store->setColumns(array_merge($storeColumns, $newColumns));
     }
     $em->merge($store);
     $em->flush();
     $executed++;
     return ['updatedRows' => $executed];
 }
 /**
  * @Route("/api/{uuid}/delete", name="api_delete")
  * @ParamConverter("api", class="AppShed\Extensions\StorageBundle\Entity\Api", options={"uuid"="uuid"})
  * @Method({"POST"})
  */
 public function deleteAction(Request $request, Api $api, $uuid)
 {
     $app = $this->getApp($request);
     $appParams = $this->getExtensionAppParameters($request);
     if ($api->getApp() != $app) {
         throw new NotFoundHttpException("Api with uuid {$uuid} not found");
     }
     $em = $this->getDoctrine()->getManager();
     $em->remove($api);
     $em->flush();
     return $this->redirect($this->generateUrl('api_list', $appParams));
 }
 /**
  * @param Api $api
  * @param array $additionalFilters;
  * @return Data[]
  */
 public function getDataForApi(Api $api, $additionalFilters = [])
 {
     return $this->getFilteredData($api->getStore(), new ArrayCollection(array_merge($api->getFilters()->toArray(), $additionalFilters)));
 }