This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
App.php
78 lines (64 loc) · 2.2 KB
/
App.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace Tests\Fixtures;
use SamJ\FractalBundle\SamJFractalBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
use Tests\Fixtures\Model\Author;
use Tests\Fixtures\Model\Book;
class App extends Kernel
{
protected function buildContainer()
{
$container = parent::buildContainer();
return $container;
}
public function boot()
{
parent::boot();
$this->populateData();
}
public function registerBundles()
{
$bundles = [
new FrameworkBundle(),
new SamJFractalBundle(),
new AppBundle(),
];
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/Resources/config.yml');
}
private function populateData()
{
$shelf = $this->getContainer()->get(Services::BOOK_SHELF);
$author = new Author('Some Author 1');
$shelf->put($this->fakeBook($author, 'Book 1'));
$shelf->put($this->fakeBook($author, 'Book 2'));
$shelf->put($this->fakeBook($author, 'Book 3'));
$shelf->put($this->fakeBook($author, 'Book 4'));
$shelf->put($this->fakeBook($author, 'Book 5'));
$shelf->put($this->fakeBook($author, 'Book 6'));
$shelf->put($this->fakeBook($author, 'Book 7'));
$author = new Author('Some Author 2');
$shelf->put($this->fakeBook($author, 'Book 8'));
$shelf->put($this->fakeBook($author, 'Book 9'));
$shelf->put($this->fakeBook($author, 'Book 10'));
$shelf->put($this->fakeBook($author, 'Book 11'));
$shelf->put($this->fakeBook($author, 'Book 12'));
$shelf->put($this->fakeBook($author, 'Book 13'));
$shelf->put($this->fakeBook($author, 'Book 14'));
}
private function fakeBook(Author $author, $name)
{
$book = new Book($name, $author);
$book->comment('Some Comment 1');
$book->comment('Some Comment 2');
$book->comment('Some Comment 3');
$book->comment('Some Comment 4');
$book->comment('Some Comment 5');
return $book;
}
}