Passed
Push — master ( 00c123...9095f7 )
by Mage
12:06 queued 09:24
created

SampleFaqData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace Mageprince\Faq\Setup\Patch\Data;
3
4
use Magento\Eav\Setup\EavSetupFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Eav\Setup\EavSetupFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Magento\Framework\Setup\ModuleDataSetupInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Setup\ModuleDataSetupInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Magento\Framework\Setup\Patch\DataPatchInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Setup\Patch\DataPatchInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class SampleFaqData implements DataPatchInterface
9
{
10
    /**
11
     * @var ModuleDataSetupInterface
12
     */
13
    protected $moduleDataSetup;
14
15
    /**
16
     * SampleFaqData constructor.
17
     *
18
     * @param ModuleDataSetupInterface $moduleDataSetup
19
     */
20
    public function __construct(
21
        ModuleDataSetupInterface $moduleDataSetup
22
    ) {
23
        $this->moduleDataSetup = $moduleDataSetup;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function apply()
30
    {
31
        $this->moduleDataSetup->getConnection()->startSetup();
32
        $setup = $this->moduleDataSetup;
33
34
        $faqGroupData = [
35
            'groupname' => 'General',
36
            'sortorder' => '1',
37
            'storeview' => '1',
38
            'customer_group' => '0,1,2,3,4',
39
            'status' => '1'
40
        ];
41
42
        $faqData = [
43
            'title' => 'This is a test FAQ question',
44
            'content' => 'This is a test FAQ answer',
45
            'group' => '1',
46
            'storeview' => '1',
47
            'customer_group' => '0,1,2,3,4',
48
            'sortorder' => '0',
49
            'status' => '1'
50
        ];
51
52
        $faqGroupTable = $setup->getTable('prince_faqgroup');
53
        $faqTable = $setup->getTable('prince_faq');
54
55
        $setup->getConnection()->insert($faqGroupTable, $faqGroupData);
56
        $setup->getConnection()->insert($faqTable, $faqData);
57
        $this->moduleDataSetup->getConnection()->endSetup();
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public static function getDependencies()
64
    {
65
        return [];
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71
    public function getAliases()
72
    {
73
        return [];
74
    }
75
}
76