| @@ 8-43 (lines=36) @@ | ||
| 5 | use Albert221\Blog\Repository\CategoryRepositoryInterface; |
|
| 6 | use Twig_Environment; |
|
| 7 | ||
| 8 | class RecentCategories implements WidgetInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var CategoryRepositoryInterface |
|
| 12 | */ |
|
| 13 | private $categories; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var Twig_Environment |
|
| 17 | */ |
|
| 18 | private $twig; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var int |
|
| 22 | */ |
|
| 23 | private $count; |
|
| 24 | ||
| 25 | public function __construct(CategoryRepositoryInterface $categories, Twig_Environment $twig, $count) |
|
| 26 | { |
|
| 27 | $this->categories = $categories; |
|
| 28 | $this->twig = $twig; |
|
| 29 | $this->count = $count; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getName() |
|
| 33 | { |
|
| 34 | return 'Ostatnie kategorie'; |
|
| 35 | } |
|
| 36 | ||
| 37 | public function getHTML() |
|
| 38 | { |
|
| 39 | $categories = $this->categories->lastCategories($this->count); |
|
| 40 | ||
| 41 | return $this->twig->render('widgets/recent_categories.twig', compact('categories')); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 8-43 (lines=36) @@ | ||
| 5 | use Albert221\Blog\Repository\PostRepositoryInterface; |
|
| 6 | use Twig_Environment; |
|
| 7 | ||
| 8 | class RecentPosts implements WidgetInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var PostRepositoryInterface |
|
| 12 | */ |
|
| 13 | private $posts; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var Twig_Environment |
|
| 17 | */ |
|
| 18 | private $twig; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var int |
|
| 22 | */ |
|
| 23 | private $count; |
|
| 24 | ||
| 25 | public function __construct(PostRepositoryInterface $posts, Twig_Environment $twig, $count) |
|
| 26 | { |
|
| 27 | $this->posts = $posts; |
|
| 28 | $this->twig = $twig; |
|
| 29 | $this->count = $count; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getName() |
|
| 33 | { |
|
| 34 | return 'Najnowsze posty'; |
|
| 35 | } |
|
| 36 | ||
| 37 | public function getHTML() |
|
| 38 | { |
|
| 39 | $posts = $this->posts->paginated(1, $this->count); |
|
| 40 | ||
| 41 | return $this->twig->render('widgets/recent_posts.twig', compact('posts')); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||