private function addDocumentForm($form, $document)
 {
     $database = new DBConnection($this->app);
     if (is_string($document)) {
         $qb = $document;
     } elseif (is_numeric($document)) {
         $qb = $database->findDocumentNameById($document);
     } else {
         $qb = $database->findAllDocuments();
     }
     $form->add($this->factory->createNamed('files', 'choice', null, array('empty_value' => 'Empty', 'auto_initialize' => false, 'choices' => ['Files' => $qb])));
     /*$form->add($this->factory->createNamed('files', 'choice', null, [
           'choices' => ['Files' => $document],
           'label' => 'Files',
       ]));*/
 }
Exemple #2
0
            $data = $download->getData();
            $filename = $documentsArray[$data['files']];
            $books = $database->findBooksFromFilename($filename);
            ExcelWorker::createExcelDocument($books, $filename);
            return new JsonResponse(Constants::EXCEL_DOWNLOAD_LOCATION . $filename);
        } else {
            return new JsonResponse(json_encode(['response' => 'File is invalid!', 'errors' => Util::getFormErrorMessages($download)]));
        }
    } catch (Exception $e) {
        return new JsonResponse($e->getMessage());
    }
})->bind('download');
$app->post('/refreshCombo', function (Request $request) use($app) {
    try {
        $database = new DBConnection($app);
        $docArray = $database->findAllDocuments();
        return new JsonResponse($docArray);
    } catch (Exception $e) {
        return new JsonResponse($e->getMessage());
    }
})->bind('refreshCombo');
/**
 * Get errors function
 */
$app->error(function (\Exception $e, Request $request, $code) use($app) {
    if ($app['debug']) {
        return;
    }
    // 404.html, or 40x.html, or 4xx.html, or error.html
    $templates = ['errors/' . $code . '.html.twig', 'errors/' . substr($code, 0, 2) . 'x.html.twig', 'errors/' . substr($code, 0, 1) . 'xx.html.twig', 'errors/default.html.twig'];
    return new Response($app['twig']->resolveTemplate($templates)->render(['code' => $code]), $code);