protected function setUp() { $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'dbname' => ':memory:']); $schema = new Schema(); MessagesSchema::create($schema); array_map([$connection, "executeQuery"], $schema->toSql($connection->getDatabasePlatform())); $doctrineDriver = new DoctrineDriver($connection); //Use the serializer provided by psb-bernard-dispatcher $this->persistentFactory = new PersistentFactory($doctrineDriver, new BernardSerializer(new FQCNMessageFactory(), new NoOpMessageConverter())); $this->bernardProducer = new Producer($this->persistentFactory, new EventDispatcher()); }
/** * Execute the console command. * * @return void */ public function fire() { global $app; /** @var EntityManager $em */ $em = $app->make('em'); MessagesSchema::create($schema = new Schema()); // setup Doctrine DBAL $connection = $em->getConnection(); $sql = $schema->toSql($connection->getDatabasePlatform()); foreach ($sql as $query) { $connection->exec($query); } $this->info('Create Doctrine schema successfully.'); }
/** * Must be defined before including bootstrap.php * as this is the only custom part in the example. */ function get_driver() { $connection = DriverManager::getConnection(array('dbname' => 'bernard', 'user' => 'root', 'password' => null, 'host' => 'localhost', 'driver' => 'pdo_mysql')); $doctrineDriver = new DoctrineDriver($connection); //Don't do this in your application. Use a database set up script instead. try { $doctrineDriver->listQueues(); } catch (\Exception $ex) { $schema = new \Doctrine\DBAL\Schema\Schema(); \Bernard\Doctrine\MessagesSchema::create($schema); array_map(array($connection, 'executeQuery'), $schema->toSql($connection->getDatabasePlatform())); } return $doctrineDriver; }
public function postGenerateSchema(GenerateSchemaEventArgs $args) { MessagesSchema::create($args->getSchema()); }