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