Completed
Push — master ( 5488c0...facaaa )
by Oscar
03:24
created

ReadEntity::json()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
1
<?php
2
3
namespace Folk\Controllers;
4
5
use Psr\Http\Message\ServerRequestInterface as Request;
6
use Psr\Http\Message\ResponseInterface as Response;
7
use Folk\Admin;
8
9
class ReadEntity extends Entity
10
{
11
    public function html(Request $request, Response $response, Admin $app, $entityName)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
12
    {
13
        $id = $request->getAttribute('id');
14
15
        $form = static::createForm($app, $entityName, $id);
16
        $form['data']->val($app->getEntity($entityName)->read($id));
17
18
        //Render template
19
        return $app['templates']->render('pages/read', [
20
            'entityName' => $entityName,
21
            'form' => $form,
22
            'id' => $id,
23
        ]);
24
    }
25
26
    public function json(Request $request, Response $response, Admin $app, $entityName)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        $id = $request->getAttribute('id');
29
30
        return json_encode($app->getEntity($entityName)->read($id));
31
    }
32
}
33