Completed
Push — master ( cd8605...3b7290 )
by
unknown
09:46
created

AddOpportunityState   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 6
Bugs 0 Features 3
Metric Value
wmc 3
c 6
b 0
f 3
lcom 1
cbo 3
dl 0
loc 58
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setExtendExtension() 0 4 1
A up() 0 4 1
B addStateField() 0 33 1
1
<?php
2
3
namespace OroCRM\Bundle\SalesBundle\Migrations\Schema\v1_22;
4
5
use Doctrine\DBAL\Schema\Schema;
6
7
use Oro\Bundle\EntityConfigBundle\Entity\ConfigModel;
8
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;
9
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;
10
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
11
use Oro\Bundle\MigrationBundle\Migration\Migration;
12
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
13
use Oro\Bundle\EntityBundle\EntityConfig\DatagridScope;
14
use Oro\Bundle\EntityExtendBundle\Migration\OroOptions;
15
16
use OroCRM\Bundle\SalesBundle\Entity\Opportunity;
17
18
class AddOpportunityState implements Migration, ExtendExtensionAwareInterface
19
{
20
    protected $extendExtension;
21
22
    /**
23
     * @param ExtendExtension $extendExtension
24
     */
25
    public function setExtendExtension(ExtendExtension $extendExtension)
26
    {
27
        $this->extendExtension = $extendExtension;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function up(Schema $schema, QueryBag $queries)
34
    {
35
        self::addStateField($schema, $this->extendExtension);
36
    }
37
38
    /**
39
     * @param Schema $schema
40
     * @param ExtendExtension $extendExtension
41
     */
42
    public static function addStateField(Schema $schema, ExtendExtension $extendExtension)
43
    {
44
        $enumTable = $extendExtension->addEnumField(
45
            $schema,
46
            'orocrm_sales_opportunity',
47
            'state',
48
            Opportunity::INTERNAL_STATE_CODE,
49
            false,
50
            false,
51
            [
52
                'extend' => ['owner' => ExtendScope::OWNER_SYSTEM],
53
                'datagrid' => ['is_visible' => DatagridScope::IS_VISIBLE_TRUE],
54
                'dataaudit' => ['auditable' => true],
55
                'importexport' => ["order" => 90, "short" => true]
56
            ]
57
        );
58
59
        $options = new OroOptions();
60
        $options->set(
61
            'enum',
62
            'immutable_codes',
63
            [
64
                'identification_alignment',
65
                'needs_analysis',
66
                'solution_development',
67
                'negotiation',
68
                'won',
69
                'lost'
70
            ]
71
        );
72
73
        $enumTable->addOption(OroOptions::KEY, $options);
0 ignored issues
show
Documentation introduced by
$options is of type object<Oro\Bundle\Entity...e\Migration\OroOptions>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74
    }
75
}
76