protected function createDefaultPages() { $pages = [['about', 'About', 'About page content goes here.'], ['privacy', 'Privacy', 'Privacy page content goes here.'], ['faq', 'FAQ', 'A list of frequently answered questions goes here.'], ['tos', 'Terms of Service', 'TOS page content goes here.']]; $em = $this->getContainer()->get('doctrine')->getManager(); foreach ($pages as $page) { $entity = $em->getRepository('OjsAdminBundle:AdminPage')->findOneBy(['slug' => $page[0]]); if (!$entity) { $entity = new AdminPage(); $entity->setVisible(true); $entity->setCurrentLocale($this->getContainer()->getParameter('locale')); $entity->setSlug($page[0]); $entity->setTitle($page[1]); $entity->setBody($page[2]); $em->persist($entity); } } $em->flush(); }