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

AddTaskStatusField::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 1 Features 1
Metric Value
c 6
b 1
f 1
dl 0
loc 16
rs 9.4285
cc 1
eloc 10
nc 1
nop 2
1
<?php
2
3
namespace OroCRM\Bundle\TaskBundle\Migrations\Schema\v1_10;
4
5
use Doctrine\DBAL\Schema\Schema;
6
7
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
8
use Oro\Bundle\MigrationBundle\Migration\Migration;
9
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension;
10
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface;
11
use Oro\Bundle\EntityExtendBundle\Migration\OroOptions;
12
use Oro\Bundle\EntityConfigBundle\Migration\UpdateEntityConfigEntityValueQuery;
13
14
class AddTaskStatusField implements Migration, ExtendExtensionAwareInterface
15
{
16
    /** @var ExtendExtension $extendExtension */
17
    protected $extendExtension;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function setExtendExtension(ExtendExtension $extendExtension)
23
    {
24
        $this->extendExtension = $extendExtension;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function up(Schema $schema, QueryBag $queries)
31
    {
32
        static::addTaskStatusField($schema, $this->extendExtension);
33
        static::addEnumValues($queries, $this->extendExtension);
34
35
        $queries->addPostQuery(new UpdateTaskStatusQuery($this->extendExtension));
36
37
        $queries->addQuery(
38
            new UpdateEntityConfigEntityValueQuery(
39
                'OroCRM\Bundle\TaskBundle\Entity\Task',
40
                'workflow',
41
                'show_step_in_grid',
42
                false
0 ignored issues
show
Documentation introduced by
false is of type boolean, 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...
43
            )
44
        );
45
    }
46
47
    /**
48
     * @param Schema          $schema
49
     * @param ExtendExtension $extendExtension
50
     */
51
    public static function addTaskStatusField(Schema $schema, ExtendExtension $extendExtension)
52
    {
53
        $enumTable = $extendExtension->addEnumField(
54
            $schema,
55
            'orocrm_task',
56
            'status',
57
            'task_status'
58
        );
59
60
        $options = new OroOptions();
61
        $options->set('enum', 'immutable_codes', ['open', 'in_progress', 'closed']);
62
63
        $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...
64
    }
65
66
    /**
67
     * @param QueryBag        $queries
68
     * @param ExtendExtension $extendExtension
69
     */
70
    public static function addEnumValues(QueryBag $queries, ExtendExtension $extendExtension)
71
    {
72
        $queries->addPostQuery(new InsertTaskStatusesQuery($extendExtension));
73
    }
74
}
75