Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Sep 9, 2016
2 parents a517a77 + 929b5aa commit e5bcfbf
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

use Oro\Bundle\EmailBundle\Entity\MailboxProcessSettings;
use Oro\Bundle\UserBundle\Entity\User;
use Oro\Bundle\TagBundle\Entity\Taggable;
use OroCRM\Bundle\CaseBundle\Model\ExtendCaseMailboxProcessSettings;

/**
* @ORM\Entity
*/
class CaseMailboxProcessSettings extends MailboxProcessSettings implements Taggable
class CaseMailboxProcessSettings extends ExtendCaseMailboxProcessSettings implements Taggable
{
/**
* @var User
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace OroCRM\Bundle\CaseBundle\Model;

use Oro\Bundle\EmailBundle\Entity\MailboxProcessSettings;

abstract class ExtendCaseMailboxProcessSettings extends MailboxProcessSettings
{
/**
* Constructor
*
* The real implementation of this method is auto generated.
*
* IMPORTANT: If the derived class has own constructor it must call parent constructor.
*/
public function __construct()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use Doctrine\ORM\Mapping as ORM;

use Oro\Bundle\EmailBundle\Entity\MailboxProcessSettings;
use Oro\Bundle\UserBundle\Entity\User;

use OroCRM\Bundle\ChannelBundle\Entity\Channel;
use OroCRM\Bundle\SalesBundle\Model\ExtendLeadMailboxProcessSettings;

/**
* @ORM\Entity
*/
class LeadMailboxProcessSettings extends MailboxProcessSettings
class LeadMailboxProcessSettings extends ExtendLeadMailboxProcessSettings
{
/**
* @var User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ protected function doExecute(LoggerInterface $logger, $dryRun = false)
*/
protected function updateWorkflowName(LoggerInterface $logger, $dryRun)
{
$workflowFields = implode(',', $this->getWorkflowFieldsByWorkflow($logger, 'b2b_flow_sales', ['name']));

$params = [
'old_workflow_name' => 'b2b_flow_sales',
'new_workflow_name' => 'opportunity_flow'
Expand All @@ -63,16 +65,9 @@ protected function updateWorkflowName(LoggerInterface $logger, $dryRun)

$queries = [
// Copy workflow definition for new opportunity flow
'INSERT INTO oro_workflow_definition ' .
'INSERT INTO oro_workflow_definition (name,' . $workflowFields . ')' .
' SELECT ' .
':new_workflow_name as name,' .
'start_step_id,' .
'label,' .
'related_entity,' .
'entity_attribute_name,' .
'steps_display_ordered,' .
'system, configuration,' .
'created_at, updated_at' .
':new_workflow_name as name,' . $workflowFields .
' FROM oro_workflow_definition WHERE name = :old_workflow_name',

'UPDATE oro_workflow_step SET workflow_name = :new_workflow_name WHERE workflow_name = :old_workflow_name',
Expand Down Expand Up @@ -108,27 +103,35 @@ protected function updateWorkflowSteps(LoggerInterface $logger, $dryRun)
[
'old_name' => 'qualify',
'new_name' => 'open',
'new_label' => 'Open',
'final' => false,
'workflow_name' => 'opportunity_flow',
],
[
'old_name' => 'develop',
'new_name' => 'won',
'new_label' => 'Won',
'final' => true,
'workflow_name' => 'opportunity_flow',
],
[
'old_name' => 'close',
'new_name' => 'lost',
'new_label' => 'Lost',
'final' => true,
'workflow_name' => 'opportunity_flow',
],
];

$types = [
'old_name' => Type::STRING,
'new_name' => Type::STRING,
'new_label' => Type::STRING,
'final' => Type::BOOLEAN,
'workflow_name' => Type::STRING,
];

$sql = 'UPDATE oro_workflow_step SET name = :new_name' .
$sql = 'UPDATE oro_workflow_step SET name = :new_name, label = :new_label, is_final = :final' .
' WHERE workflow_name = :workflow_name AND name = :old_name';
foreach ($params as $param) {
$this->logQuery($logger, $sql, $param, $types);
Expand All @@ -139,6 +142,8 @@ protected function updateWorkflowSteps(LoggerInterface $logger, $dryRun)
/**
* @param LoggerInterface $logger
* @param bool $dryRun
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function updateWorkflowTransitionLogs(LoggerInterface $logger, $dryRun)
{
Expand Down Expand Up @@ -332,4 +337,27 @@ protected function getWorkflowSteps(LoggerInterface $logger)

return $this->connection->fetchAll($sql, $params, $types);
}

/**
* @param LoggerInterface $logger
* @param string $name
* @param array $exclude
* @return array
*/
protected function getWorkflowFieldsByWorkflow(LoggerInterface $logger, $name, array $exclude)
{
$params = ['workflow_name' => $name];
$types = ['workflow_name' => Type::STRING];

$sql = 'SELECT * FROM oro_workflow_definition WHERE name = :workflow_name LIMIT 1';
$this->logQuery($logger, $sql, $params, $types);

$fields = $this->connection->executeQuery($sql, $params, $types)->fetch();

foreach ($exclude as $field) {
unset($fields[$field]);
}

return array_keys($fields);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace OroCRM\Bundle\SalesBundle\Model;

use Oro\Bundle\EmailBundle\Entity\MailboxProcessSettings;

abstract class ExtendLeadMailboxProcessSettings extends MailboxProcessSettings
{
/**
* Constructor
*
* The real implementation of this method is auto generated.
*
* IMPORTANT: If the derived class has own constructor it must call parent constructor.
*/
public function __construct()
{
}
}

0 comments on commit e5bcfbf

Please sign in to comment.