1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Faker |
5
|
|
|
* @author Iurii Makukh <[email protected]> |
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh <[email protected]> |
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License 3.0 |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace gplcart\modules\faker\models\generators; |
11
|
|
|
|
12
|
|
|
use gplcart\core\models\Page as PageModel; |
13
|
|
|
use gplcart\modules\faker\models\Generator as FakerModuleGenerator; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Manages basic behaviors and data related to pages |
17
|
|
|
*/ |
18
|
|
|
class Page extends FakerModuleGenerator |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Page model class instance |
23
|
|
|
* @var \gplcart\core\models\Page $page |
24
|
|
|
*/ |
25
|
|
|
protected $page; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param PageModel $page |
29
|
|
|
*/ |
30
|
|
|
public function __construct(PageModel $page) |
31
|
|
|
{ |
32
|
|
|
parent::__construct(); |
33
|
|
|
|
34
|
|
|
$this->page = $page; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the generator name |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
|
|
public function getName() |
42
|
|
|
{ |
43
|
|
|
return $this->translation->text('Page'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Generate a single page |
48
|
|
|
* @return bool |
49
|
|
|
*/ |
50
|
|
|
public function create() |
51
|
|
|
{ |
52
|
|
|
$page = array( |
53
|
|
|
'user_id' => $this->getUserId(), |
54
|
|
|
'store_id' => $this->getStoreId(), |
55
|
|
|
'title' => $this->faker->text(100), |
56
|
|
|
'status' => $this->faker->boolean(), |
57
|
|
|
'description' => $this->faker->text(1000), |
58
|
|
|
'category_id' => $this->getCategoryId('catalog'), |
59
|
|
|
'meta_title' => $this->faker->text(60), |
60
|
|
|
'meta_description' => $this->faker->text(160), |
61
|
|
|
'alias' => $this->getAlias(), |
62
|
|
|
'images' => $this->getImages() |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
return (bool) $this->page->add($page); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|