Completed
Push — master ( 9ac2da...db41a2 )
by WEBEWEB
16:50
created

WikiController::getSyntaxHighlighterDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\BootstrapBundle\Controller;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use WBW\Bundle\BootstrapBundle\Model\WikiPage;
17
18
/**
19
 * Wiki controller.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\BootstrapBundle\Controller
23
 */
24
class WikiController extends AbstractWikiController {
25
26
    /**
27
     * Get the wiki pages.
28
     *
29
     * @return WikiPage[] Returns the wiki pages.
30
     */
31
    public static function getWikiPages() {
32
33
        // Initialize the table of contents.
34
        $tableContents = [];
35
36
        // Twig extensions > Code
37
        $tableContents[] = new WikiPage("twig-extension", "code", "basic-block", "Basic block");
38
        $tableContents[] = new WikiPage("twig-extension", "code", "inline", "Inline");
39
        $tableContents[] = new WikiPage("twig-extension", "code", "sample-output", "Sample output");
40
        $tableContents[] = new WikiPage("twig-extension", "code", "user-input", "User input");
41
        $tableContents[] = new WikiPage("twig-extension", "code", "variable", "Variable");
42
43
        // Twig extensions > Component
44
        $tableContents[] = new WikiPage("twig-extension", "component", "alert", "Alert");
45
        $tableContents[] = new WikiPage("twig-extension", "component", "badge", "Badge");
46
        $tableContents[] = new WikiPage("twig-extension", "component", "button", "Button");
47
        $tableContents[] = new WikiPage("twig-extension", "component", "glyphicon", "Glyphicon");
48
        $tableContents[] = new WikiPage("twig-extension", "component", "label", "Label");
49
        $tableContents[] = new WikiPage("twig-extension", "component", "progress-bar", "Progress bar");
50
51
        // Twig extensions > Form
52
        $tableContents[] = new WikiPage("twig-extension", "form", "button", "Button");
53
54
        // Twig extensions > Grid
55
        $tableContents[] = new WikiPage("twig-extension", "grid", "grid", "Grid");
56
57
        // Twig extensions > Image
58
        $tableContents[] = new WikiPage("twig-extension", "image", "base64", "Base 64");
59
60
        // Twig extensions > Plugin
61
        $tableContents[] = new WikiPage("twig-extension", "plugin", "font-awesome", "Font Awesome");
62
        $tableContents[] = new WikiPage("twig-extension", "plugin", "jquery-inputmask", "jQuery InputMask");
63
        $tableContents[] = new WikiPage("twig-extension", "plugin", "material-design-iconic-font", "Material Design Iconic Font");
64
        $tableContents[] = new WikiPage("twig-extension", "plugin", "meteocons", "Meteocons");
65
66
        // Twig extensions > Table
67
        $tableContents[] = new WikiPage("twig-extension", "table", "button", "Button");
68
69
        // Twig extensions > Typography
70
        $tableContents[] = new WikiPage("twig-extension", "typography", "bold", "Bold");
71
        $tableContents[] = new WikiPage("twig-extension", "typography", "deleted", "Deleted");
72
        $tableContents[] = new WikiPage("twig-extension", "typography", "heading", "Heading");
73
        $tableContents[] = new WikiPage("twig-extension", "typography", "inserted", "Inserted");
74
        $tableContents[] = new WikiPage("twig-extension", "typography", "italic", "Italic");
75
        $tableContents[] = new WikiPage("twig-extension", "typography", "marked", "Marked");
76
        $tableContents[] = new WikiPage("twig-extension", "typography", "small", "Small");
77
        $tableContents[] = new WikiPage("twig-extension", "typography", "strikethrough", "Strikethrough");
78
        $tableContents[] = new WikiPage("twig-extension", "typography", "underlined", "Underlined");
79
80
        // Twig extensions > Utility
81
        $tableContents[] = new WikiPage("twig-extension", "utility", "role-label", "Role label");
82
83
        // Return the table of contents.
84
        return $tableContents;
85
    }
86
87
    /**
88
     * Displays a wiki page.
89
     *
90
     * @param Request $request The request.
91
     * @param string $category The category.
92
     * @param string $package The parent.
93
     * @param string $page The page.
94
     * @return Response Returns the response.
95
     */
96
    public function indexAction(Request $request, $category, $package, $page) {
1 ignored issue
show
Unused Code introduced by
The parameter $request 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...
97
98
        // Initialize.
99
        $wikiPages = self::getWikiPages();
100
        $wikiPage  = null;
101
102
        // Find the wiki page.
103
        foreach ($wikiPages as $current) {
104
            if ($category === $current->getCategory() && $package === $current->getPackage() && $page === $current->getPage()) {
105
                $wikiPage = $current;
106
                break;
107
            }
108
        }
109
110
        // Check if the wiki page exists.
111
        if (null === $wikiPage) {
112
113
            // Set the default wiki page.
114
            $wikiPage = $wikiPages[0];
115
116
            // Notify the user.
117
            $this->notifyDanger("The requested page was not found");
118
            $this->notifyInfo("You have been redirected to homepage");
119
        }
120
121
        // Set the template.
122
        $template = [
123
            "@",
124
            $wikiPage->getBundle(),
125
            "/Wiki/",
126
            $wikiPage->getCategory(),
127
            "/",
128
            $wikiPage->getPackage(),
129
            "/",
130
            $wikiPage->getPage(),
131
            ".html.twig",
132
        ];
133
134
        // Returns the response.
135
        return $this->render(implode("", $template), [
136
                "wikiPage"                  => $wikiPage,
137
                "wikiPages"                 => $wikiPages,
138
                "syntaxHighlighterConfig"   => $this->getSyntaxHighlighterConfig(),
139
                "syntaxHighlighterDefaults" => $this->getSyntaxHighlighterDefaults(),
140
                "user"                      => $this->getUser(),
141
                "userRoleColors"            => $this->getUserRoleColors(),
142
                "userRoleTranslations"      => $this->getUserRoleTranslations(),
143
        ]);
144
    }
145
146
}
147