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