Completed
Push — master ( 1a117b...43f8bd )
by Mikael
11:04
created

src/Content/FileBasedContentController.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Anax\Controller;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
/**
9
 * A controller for flat file markdown content.
10
 */
11
class FileBasedContentController implements ContainerInjectableInterface
12
{
13
    use ContainerInjectableTrait;
14
15
16
17
    /**
18
     * Render a page using flat file content.
19
     *
20
     * @param array $args as a variadic to catch all arguments.
21
     *
22
     * @return mixed as null when flat file is not found and otherwise a
23
     *               complete response object with content to render.
24
     *
25
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
26
     */
27
    public function catchAll(...$args)
0 ignored issues
show
The parameter $args 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...
28
    {
29
        $content = $this->di->get("content");
30
        $page = $this->di->get("page");
31
        
32
        $fileContent = $content->contentForRoute();
33
        foreach ($fileContent->views as $view) {
34
            $page->add($view);
35
        }
36
        
37
        $page->add("anax/v2/article/default", [
38
            "content" => $fileContent->text,
39
            "frontmatter" => $fileContent->frontmatter,
40
        ]);
41
        
42
        return $page->render($fileContent->frontmatter);
43
    }
44
}
45