Completed
Push — develop ( 058245...bd9d6f )
by Narcotic
12s
created

HomepageRenderEvent::getRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * event object when the homepage is rendered
4
 */
5
6
namespace Graviton\CoreBundle\Event;
7
8
use Symfony\Component\EventDispatcher\Event;
9
10
/**
11
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
12
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
13
 * @link     http://swisscom.ch
14
 */
15
final class HomepageRenderEvent extends Event
16
{
17
    /**
18
     * our event name
19
     *
20
     * @var string
21
     */
22
    const EVENT_NAME = 'homepage.render';
23
24
    /**
25
     * added routes
26
     *
27
     * @var array
28
     */
29
    private $addedRoutes = [];
30
31
    /**
32
     * add a route to the homepage
33
     *
34
     * @param string $url       relative (to root) url to the service
35
     * @param string $schemaUrl relative (to root) url to the schema
36
     *
37
     * @return void
38
     */
39
    public function addRoute($url, $schemaUrl)
40
    {
41
        if (substr($url, 0, 1) == '/') {
42
            $url = substr($url, 1);
43
        }
44
        if (substr($schemaUrl, 0, 1) == '/') {
45
            $schemaUrl = substr($schemaUrl, 1);
46
        }
47
48
        $this->addedRoutes[] = [
49
            '$ref' => $url,
50
            'profile' => $schemaUrl
51
        ];
52
    }
53
54
    /**
55
     * returns the routes
56
     *
57
     * @return array routes
58
     */
59
    public function getRoutes()
60
    {
61
        return $this->addedRoutes;
62
    }
63
}
64