get('entityManager'); $this->updateTemplates($entityManager); } protected function updateTemplates($entityManager) { $templateList = $entityManager ->getRepository('Template') ->where([ 'printHeader' => false, ['header!=' => null], ['header!=' => ''], ]) ->find(); foreach ($templateList as $template) { $body = $template->get('header') . ($template->get('body') ?? ''); $template->set('body', $body); $template->set('header', null); $entityManager->saveEntity($template); } } }