/
Control.php
61 lines (50 loc) · 1.08 KB
/
Control.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
<?php
namespace Ytnuk\Blog;
use Nette;
use Ytnuk;
final class Control
extends Ytnuk\Application\Control
{
/**
* @var Category\Control\Factory
*/
private $categoryControl;
/**
* @var Post\Control\Factory
*/
private $postControl;
/**
* @var Category\Entity
*/
private $category;
/**
* @var Post\Entity
*/
private $post;
public function __construct(
Category\Control\Factory $categoryControl,
Post\Control\Factory $postControl
) {
parent::__construct();
$this->categoryControl = $categoryControl;
$this->postControl = $postControl;
}
public function setCategory(Ytnuk\Blog\Category\Entity $category)
{
$this->category = $category;
unset($this['category']);
}
public function setPost(Ytnuk\Blog\Post\Entity $post)
{
$this->post = $post;
unset($this['post']);
}
protected function createComponentCategory() : Category\Control
{
return $this->categoryControl->create($this->category ? : new Category\Entity);
}
protected function createComponentPost() : Post\Control
{
return $this->postControl->create($this->post ? : new Post\Entity);
}
}