-
Notifications
You must be signed in to change notification settings - Fork 0
/
Control.php
61 lines (50 loc) · 1.14 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\Shop;
use Nette;
use Ytnuk;
final class Control
extends Ytnuk\Application\Control
{
/**
* @var Category\Control\Factory
*/
private $categoryControl;
/**
* @var Product\Control\Factory
*/
private $productControl;
/**
* @var Category\Entity
*/
private $category;
/**
* @var Product\Entity
*/
private $product;
public function __construct(
Category\Control\Factory $categoryControl,
Product\Control\Factory $productControl
) {
parent::__construct();
$this->categoryControl = $categoryControl;
$this->productControl = $productControl;
}
public function setCategory(Ytnuk\Shop\Category\Entity $category)
{
$this->category = $category;
unset($this['category']);
}
public function setProduct(Ytnuk\Shop\Product\Entity $product)
{
$this->product = $product;
unset($this['product']);
}
protected function createComponentCategory() : Category\Control
{
return $this->categoryControl->create($this->category ? : new Category\Entity);
}
protected function createComponentProduct() : Product\Control
{
return $this->productControl->create($this->product ? : new Product\Entity);
}
}