Conditions | 2 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2.003 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 1 | public function connect(Application $app, $schema='/schema/index') |
|
23 | { |
||
24 | 1 | $resource = $app["resources_factory"]($schema); |
|
25 | 1 | $app["twig.loader"]->addLoader(new Twig_Loader_Filesystem(__DIR__ . "/templates")); |
|
26 | 1 | $app->before(new AddSchema($schema, "index")); |
|
27 | // Generate default Index resource |
||
28 | 1 | $resource->before(function (Request $request, Application $app) { |
|
29 | 1 | $index = $app["url_generator"]->generate("index"); |
|
30 | 1 | if (!$this->service->contains($index)) { |
|
31 | $this->service->save($index, json_decode($app["twig"]->render("default.json.twig"))); |
||
32 | } |
||
33 | 1 | }); |
|
34 | 1 | $resource->get("/", new GetResourceController($this->service))->bind("index"); |
|
35 | 1 | return $resource; |
|
36 | } |
||
37 | } |
||
38 |