This topic contains 3 replies, has 2 voices, and was last updated by Yevhen Shyshkin 8 years, 5 months ago.
- Topic
Hello, I want to automation workflow to send email, etc.
I create a command but I have a performance problem.
/** @var \Doctrine\ORM\EntityManager $em */
$em = $this->getContainer()->get('doctrine.orm.entity_manager');$workflowItems = $em->createQueryBuilder()
->select('wi')
->from('OroWorkflowBundle:WorkflowItem', 'wi')
->from('OroWorkflowBundle:WorkflowStep', 'ws')
->where('wi.currentStep = ws.id')
->andWhere('wi.definition = \'main_workflow\'')
->andWhere('ws.final=0')
->getQuery()->getResult();$user = $this->getContainer()->get('doctrine')->getRepository('OroUserBundle:User')->findOneBy(['username' => 'admin']);
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->getContainer()->get('security.context')->setToken($token);$workflowManager = $this->getWorkflowManager();
foreach ($workflowItems as $workflowItem)
{
$transitions = $workflowManager->getTransitionsByWorkflowItem($workflowItem);foreach ($transitions as $transition) {
if($workflowManager->isTransitionAvailable($workflowItem, $transition)) {
$workflowManager->transit($workflowItem, $transition);
break;
}
}
}
Have you an idea to update a code ?
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.