-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.php
50 lines (39 loc) · 1.17 KB
/
basic.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
<?php
use Model\Repository\BookRepository;
use Model\Repository\AuthorRepository;
require_once __DIR__ . '/app/bootstrap.php';
$bookRepository = new BookRepository($connection, $mapper, $entityFactory);
$authorRepository = new AuthorRepository($connection, $mapper, $entityFactory);
$books = $bookRepository->findAll();
superscribe('Přehled knih a výpůjček');
foreach ($books as $book) {
write($book->name);
write('Autor: ' . $book->author->name);
write('Výpůjčky:');
foreach ($book->borrowings as $borrowing) {
write($borrowing->borrower->name . '(' . $borrowing->date . ')', 3);
}
separate();
}
superscribe('Autorství a recenzenství');
$authors = $authorRepository->findAll();
foreach ($authors as $author) {
write($author->name);
write('Je autorem:');
foreach ($author->books as $book) {
write($book->name, 3);
}
write('Recenzoval:');
foreach ($author->reviewedBooks as $book) {
write($book->name, 3);
}
separate();
}
superscribe('Tagy, které souvisí s autory');
foreach ($authors as $author) {
write($author->name);
foreach ($author->referencingTags as $tag) {
write($tag->name, 3);
}
separate();
}