-
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
22 changed files
with
517 additions
and
47 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
69 changes: 69 additions & 0 deletions
69
src/Oro/Bundle/EmailBundle/Command/UpdateAssociationsCommand.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,69 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\EmailBundle\Command; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use JMS\JobQueueBundle\Entity\Job; | ||
use Oro\Bundle\EmailBundle\Command\Manager\AssociationManager; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class UpdateAssociationsCommand extends ContainerAwareCommand | ||
{ | ||
const NAME = 'oro:email:update-associations'; | ||
const OPTION_FOREGROUND = 'foreground'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('oro:email:update-associations') | ||
->setDescription('Update associations to emails') | ||
->addOption( | ||
static::OPTION_FOREGROUND, | ||
'f', | ||
InputOption::VALUE_NONE, | ||
'Schedule jobs in backround and exits immediately' | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
if ($input->getOption(static::OPTION_FOREGROUND)) { | ||
$this | ||
->getCommandAssociationManager() | ||
->processUpdateAllEmailOwners(); | ||
} else { | ||
$job = new Job(static::NAME, ['--foreground']); | ||
|
||
$em = $this->getJobManager(); | ||
$em->persist($job); | ||
$em->flush(); | ||
} | ||
|
||
$output->writeln('<info>Update of associations has been scheduled.</info>'); | ||
} | ||
|
||
/** | ||
* @return EntityManager | ||
*/ | ||
public function getJobManager() | ||
{ | ||
return $this->getContainer()->get('doctrine')->getManagerForClass(Job::class); | ||
} | ||
|
||
/** | ||
* @return AssociationManager | ||
*/ | ||
protected function getCommandAssociationManager() | ||
{ | ||
return $this->getContainer()->get('oro_email.command.association_manager'); | ||
} | ||
} |
Oops, something went wrong.