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