/** * @param EntityManager $em */ public static function createDbSchema(EntityManager $em) { $tool = new SchemaTool($em); $classes = array($em->getClassMetadata('Secretary\\Entity\\User'), $em->getClassMetadata('Secretary\\Entity\\Role'), $em->getClassMetadata('Secretary\\Entity\\Key'), $em->getClassMetadata('Secretary\\Entity\\Note'), $em->getClassMetadata('Secretary\\Entity\\User2Note')); $tool->createSchema($classes); $guestRole = new \Secretary\Entity\Role(); $guestRole->setId(1)->setDefault(true)->setRoleId('guest'); $userRole = new \Secretary\Entity\Role(); $userRole->setId(2)->setDefault(false)->setRoleId('user'); $keyUserRole = new \Secretary\Entity\Role(); $keyUserRole->setId(3)->setDefault(false)->setParent($userRole)->setRoleId('keyuser'); $adminUserRole = new \Secretary\Entity\Role(); $adminUserRole->setId(4)->setDefault(false)->setParent($keyUserRole)->setRoleId('admin'); $em->persist($guestRole); $em->persist($userRole); $em->persist($keyUserRole); $em->persist($adminUserRole); $em->flush(); }
protected function createDbSchema() { $this->em = $this->getApplicationServiceLocator()->get('doctrine.entitymanager.ormdefault'); $tool = new SchemaTool($this->em); $classes = array($this->em->getClassMetadata('Secretary\\Entity\\User'), $this->em->getClassMetadata('Secretary\\Entity\\Role'), $this->em->getClassMetadata('Secretary\\Entity\\Key'), $this->em->getClassMetadata('Secretary\\Entity\\Note'), $this->em->getClassMetadata('Secretary\\Entity\\User2Note')); $tool->createSchema($classes); $guestRole = new \Secretary\Entity\Role(); $guestRole->setId(1)->setDefault(true)->setRoleId('guest'); $userRole = new \Secretary\Entity\Role(); $userRole->setId(2)->setDefault(false)->setRoleId('user'); $keyUserRole = new \Secretary\Entity\Role(); $keyUserRole->setId(3)->setDefault(false)->setParent($userRole)->setRoleId('keyuser'); $adminUserRole = new \Secretary\Entity\Role(); $adminUserRole->setId(4)->setDefault(false)->setParent($keyUserRole)->setRoleId('admin'); $this->em->persist($guestRole); $this->em->persist($userRole); $this->em->persist($keyUserRole); $this->em->persist($adminUserRole); $this->em->flush(); }