1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\CaseBundle\Migrations\Schema\v1_8; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
6
|
|
|
|
7
|
|
|
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension; |
8
|
|
|
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface; |
9
|
|
|
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtension; |
10
|
|
|
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtensionAwareInterface; |
11
|
|
|
use Oro\Bundle\MigrationBundle\Migration\Migration; |
12
|
|
|
use Oro\Bundle\MigrationBundle\Migration\QueryBag; |
13
|
|
|
|
14
|
|
View Code Duplication |
class CreateActivityAssociation implements Migration, ActivityExtensionAwareInterface, NoteExtensionAwareInterface |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
/** @var ActivityExtension */ |
17
|
|
|
protected $activityExtension; |
18
|
|
|
|
19
|
|
|
/** @var NoteExtension */ |
20
|
|
|
protected $noteExtension; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function setActivityExtension(ActivityExtension $activityExtension) |
26
|
|
|
{ |
27
|
|
|
$this->activityExtension = $activityExtension; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function setNoteExtension(NoteExtension $noteExtension) |
34
|
|
|
{ |
35
|
|
|
$this->noteExtension = $noteExtension; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
|
|
public function up(Schema $schema, QueryBag $queries) |
42
|
|
|
{ |
43
|
|
|
self::addActivityAssociations($schema, $this->activityExtension); |
44
|
|
|
self::addNoteAssociations($schema, $this->noteExtension); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Enable activities |
49
|
|
|
* |
50
|
|
|
* @param Schema $schema |
51
|
|
|
* @param ActivityExtension $activityExtension |
52
|
|
|
*/ |
53
|
|
|
public static function addActivityAssociations(Schema $schema, ActivityExtension $activityExtension) |
54
|
|
|
{ |
55
|
|
|
$activityExtension->addActivityAssociation($schema, 'orocrm_call', 'orocrm_case'); |
56
|
|
|
$activityExtension->addActivityAssociation($schema, 'orocrm_task', 'orocrm_case'); |
57
|
|
|
$activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_case'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Enable notes for Case entity |
62
|
|
|
* |
63
|
|
|
* @param Schema $schema |
64
|
|
|
* @param NoteExtension $noteExtension |
65
|
|
|
*/ |
66
|
|
|
public static function addNoteAssociations(Schema $schema, NoteExtension $noteExtension) |
67
|
|
|
{ |
68
|
|
|
$noteExtension->addNoteAssociation($schema, 'orocrm_case'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.