-
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.7' into 1.7
- Loading branch information
Showing
64 changed files
with
1,232 additions
and
275 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
86 changes: 86 additions & 0 deletions
86
src/Oro/Bundle/ActivityListBundle/Migrations/Data/ORM/UpdateEmailActivityListDescription.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,86 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ActivityListBundle\Migrations\Data\ORM; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
use Doctrine\Common\DataFixtures\AbstractFixture; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Doctrine\ORM\QueryBuilder; | ||
|
||
use Oro\Bundle\EmailBundle\Entity\Email; | ||
use Oro\Bundle\BatchBundle\ORM\Query\BufferedQueryResultIterator; | ||
|
||
class UpdateEmailActivityListDescription extends AbstractFixture implements ContainerAwareInterface | ||
{ | ||
const BATCH_SIZE = 500; | ||
|
||
/** @var ContainerInterface */ | ||
protected $container; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setContainer(ContainerInterface $container = null) | ||
{ | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(ObjectManager $manager) | ||
{ | ||
$this->updateEmailActivityDescription($manager); | ||
} | ||
|
||
/** | ||
* Update activity | ||
* @param ObjectManager $manager | ||
*/ | ||
public function updateEmailActivityDescription(ObjectManager $manager) | ||
{ | ||
/** @var QueryBuilder $activityListBuilder */ | ||
$activityListBuilder = $manager->getRepository('OroActivityListBundle:ActivityList')->createQueryBuilder('e'); | ||
|
||
$iterator = new BufferedQueryResultIterator($activityListBuilder); | ||
$iterator->setBufferSize(self::BATCH_SIZE); | ||
|
||
$itemsCount = 0; | ||
$entities = []; | ||
$emailRepository = $manager->getRepository('OroEmailBundle:Email'); | ||
$activityProvider = $this->container->get('oro_email.activity_list.provider'); | ||
|
||
foreach ($iterator as $activity) { | ||
$email = $emailRepository->find($activity->getRelatedActivityId()); | ||
if ($email) { | ||
$itemsCount++; | ||
$activity->setDescription($activityProvider->getDescription($email)); | ||
$entities[] = $activity; | ||
} | ||
if (0 === $itemsCount % self::BATCH_SIZE) { | ||
$this->saveEntities($manager, $entities); | ||
$entities = []; | ||
} | ||
} | ||
|
||
if ($itemsCount % self::BATCH_SIZE > 0) { | ||
$this->saveEntities($manager, $entities); | ||
} | ||
} | ||
|
||
/** | ||
* @param ObjectManager $manager | ||
* @param array $entities | ||
*/ | ||
protected function saveEntities(ObjectManager $manager, array $entities) | ||
{ | ||
foreach ($entities as $activity) { | ||
$manager->persist($activity); | ||
} | ||
$manager->flush(); | ||
$manager->clear(); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/Oro/Bundle/ActivityListBundle/Migrations/Schema/v1_2/AddActivityDescription.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,30 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ActivityListBundle\Migrations\Schema\v1_2; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
use Oro\Bundle\MigrationBundle\Migration\Migration; | ||
use Oro\Bundle\MigrationBundle\Migration\QueryBag; | ||
|
||
class AddActivityDescription implements Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function up(Schema $schema, QueryBag $queries) | ||
{ | ||
self::addColumns($schema); | ||
} | ||
|
||
/** | ||
* Add description to activity list | ||
* | ||
* @param Schema $schema | ||
*/ | ||
public static function addColumns(Schema $schema) | ||
{ | ||
$table = $schema->getTable('oro_activity_list'); | ||
$table->addColumn('description', 'text', ['notnull' => false]); | ||
} | ||
} |
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
Oops, something went wrong.