-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
- Loading branch information
Showing
64 changed files
with
1,921 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Oro/Bundle/EmailBundle/Command/ConvertEmailBodyToTextBody.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\EmailBundle\Command; | ||
|
||
use Doctrine\DBAL\Connection; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
use Oro\Bundle\EmailBundle\Tools\EmailBodyHelper; | ||
|
||
/** | ||
* Converts email body representations. | ||
* Will be deleted in 2.0 | ||
*/ | ||
class ConvertEmailBodyToTextBody extends ContainerAwareCommand | ||
{ | ||
const COMMAND_NAME = 'oro:email:convert-body-to-text'; | ||
|
||
const BATCH_SIZE = 500; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName(static::COMMAND_NAME) | ||
->setDescription('Converts emails body. Generates and stores textual email body representation.'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln('<info>Conversion of emails body is started.</info>'); | ||
|
||
/** @var Connection $connection */ | ||
$connection = $this->getContainer()->get('doctrine')->getConnection(); | ||
|
||
$tableName = $this->queryHelper->getTableName('Oro\Bundle\EmailBundle\Entity\EmailBody'); | ||
$selectQuery = 'select id, body from ' . $tableName . ' where body is not null and text_body is null ' | ||
. 'order by created desc limit :limit offset :offset'; | ||
$pageNumber = 0; | ||
$emailBodyHelper = new EmailBodyHelper(); | ||
while (true) { | ||
$output->writeln(sprintf('<info>Process page %s.</info>', $pageNumber + 1)); | ||
$data = $connection->fetchAll( | ||
$selectQuery, | ||
['limit' => self::BATCH_SIZE, 'offset' => self::BATCH_SIZE * $pageNumber], | ||
['limit' => 'integer', 'offset' => 'integer'] | ||
); | ||
|
||
// exit if we have no data anymore | ||
if (count($data) === 0) { | ||
break; | ||
} | ||
|
||
foreach ($data as $dataArray) { | ||
$connection->update( | ||
$tableName, | ||
['text_body' => $emailBodyHelper->getTrimmedClearText($dataArray['body'])], | ||
['id' => $dataArray['id']], | ||
['textBody' => 'string'] | ||
); | ||
} | ||
|
||
$pageNumber++; | ||
} | ||
|
||
$output->writeln('<info>Job complete.</info>'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.