本文整理汇总了PHP中Doctrine\ORM\Tools\SchemaTool类的典型用法代码示例。如果您正苦于以下问题:PHP SchemaTool类的具体用法?PHP SchemaTool怎么用?PHP SchemaTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SchemaTool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: adminRefreshDatabaseAction
public function adminRefreshDatabaseAction(Request $request, Application $app)
{
$conn = $app['db'];
$em = $app['doctrine.orm.entity_manager'];
$params = $conn->getParams();
$name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
try {
$conn->getSchemaManager()->dropDatabase($name);
$conn->getSchemaManager()->createDatabase($name);
$conn->close();
} catch (\Exception $e) {
return 1;
}
$classes = [];
foreach ($app['authbucket_oauth2.model'] as $class) {
$classes[] = $em->getClassMetadata($class);
}
PersistentObject::setObjectManager($em);
$tool = new SchemaTool($em);
$tool->dropSchema($classes);
$tool->createSchema($classes);
$purger = new ORMPurger();
$executor = new ORMExecutor($em, $purger);
$loader = new Loader();
$loader->loadFromDirectory(__DIR__ . '/../DataFixtures/ORM');
$executor->execute($loader->getFixtures());
return $app->redirect($app['url_generator']->generate('index'));
}
开发者ID:miguelbemartin,项目名称:oauth2-php,代码行数:28,代码来源:DefaultController.php
示例2: setUp
protected function setUp()
{
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine is not available.');
}
$this->em = DoctrineOrmTestCase::createTestEntityManager();
parent::setUp();
$schemaTool = new SchemaTool($this->em);
$classes = array(
$this->em->getClassMetadata(self::SINGLE_IDENT_CLASS),
$this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS),
$this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS),
$this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS),
);
try {
$schemaTool->dropSchema($classes);
} catch(\Exception $e) {
}
try {
$schemaTool->createSchema($classes);
} catch(\Exception $e) {
}
}
开发者ID:naknak,项目名称:symfony,代码行数:28,代码来源:EntityTypeTest.php
示例3: setUp
public function setUp()
{
$this->_oldEntityManager = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager();
$this->_oldAuditedClassNames = \SoliantEntityAudit\Module::getModuleOptions()->getAuditedClassNames();
$this->_oldJoinClasses = \SoliantEntityAudit\Module::getModuleOptions()->resetJoinClasses();
$isDevMode = false;
$config = Setup::createConfiguration($isDevMode, null, null);
$chain = new DriverChain();
// Use ZFC User for authentication tests
$chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuser'), 'ZfcUser\\Entity');
$chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuserdoctrineorm'), 'ZfcUserDoctrineORM\\Entity');
$chain->addDriver(new StaticPHPDriver(__DIR__ . "/../Models"), 'SoliantEntityAuditTest\\Models\\LogRevision');
$chain->addDriver(new AuditDriver('.'), 'SoliantEntityAudit\\Entity');
$config->setMetadataDriverImpl($chain);
// Replace entity manager
$moduleOptions = \SoliantEntityAudit\Module::getModuleOptions();
$conn = array('driver' => 'pdo_sqlite', 'memory' => true);
$moduleOptions->setAuditedClassNames(array('SoliantEntityAuditTest\\Models\\LogRevision\\Album' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Performer' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Song' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\SingleCoverArt' => array()));
$entityManager = EntityManager::create($conn, $config);
$moduleOptions->setEntityManager($entityManager);
$schemaTool = new SchemaTool($entityManager);
// Add auditing listener
$entityManager->getEventManager()->addEventSubscriber(new LogRevision());
$sql = $schemaTool->getUpdateSchemaSql($entityManager->getMetadataFactory()->getAllMetadata());
#print_r($sql);die();
$schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
$this->_em = $entityManager;
}
开发者ID:VOONWerbeagentur,项目名称:SoliantEntityAudit,代码行数:28,代码来源:LogRevisionTest.php
示例4: setUp
protected function setUp()
{
if (!class_exists('Symfony\\Component\\Form\\Form')) {
$this->markTestSkipped('The "Form" component is not available');
}
if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
$this->markTestSkipped('Doctrine DBAL is not available.');
}
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine Common is not available.');
}
if (!class_exists('Doctrine\\ORM\\EntityManager')) {
$this->markTestSkipped('Doctrine ORM is not available.');
}
$this->em = DoctrineOrmTestCase::createTestEntityManager();
$this->emRegistry = $this->createRegistryMock('default', $this->em);
parent::setUp();
$schemaTool = new SchemaTool($this->em);
$classes = array($this->em->getClassMetadata(self::ITEM_GROUP_CLASS), $this->em->getClassMetadata(self::SINGLE_IDENT_CLASS), $this->em->getClassMetadata(self::SINGLE_STRING_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_IDENT_CLASS), $this->em->getClassMetadata(self::COMPOSITE_STRING_IDENT_CLASS));
try {
$schemaTool->dropSchema($classes);
} catch (\Exception $e) {
}
try {
$schemaTool->createSchema($classes);
} catch (\Exception $e) {
}
}
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:28,代码来源:EntityTypeTest.php
示例5: setUp
public function setUp()
{
parent::setUp();
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
$schemaTool = new SchemaTool($em);
$schemaTool->createSchema($em->getMetadataFactory()->getAllMetadata());
}
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:7,代码来源:NestedResourceSubscriberTest.php
示例6: setUp
public function setUp()
{
parent::setUp();
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->createSchema(array($this->entityManager->getClassMetadata('Pagerfanta\\Tests\\Adapter\\DoctrineORM\\User'), $this->entityManager->getClassMetadata('Pagerfanta\\Tests\\Adapter\\DoctrineORM\\Group'), $this->entityManager->getClassMetadata('Pagerfanta\\Tests\\Adapter\\DoctrineORM\\Person')));
$this->user1 = $user = new User();
$this->user2 = $user2 = new User();
$group1 = new Group();
$group2 = new Group();
$group3 = new Group();
$user->groups[] = $group1;
$user->groups[] = $group2;
$user->groups[] = $group3;
$user2->groups[] = $group1;
$author1 = new Person();
$author1->name = 'Foo';
$author1->biography = 'Baz bar';
$author2 = new Person();
$author2->name = 'Bar';
$author2->biography = 'Bar baz';
$this->entityManager->persist($user);
$this->entityManager->persist($user2);
$this->entityManager->persist($group1);
$this->entityManager->persist($group2);
$this->entityManager->persist($group3);
$this->entityManager->persist($author1);
$this->entityManager->persist($author2);
$this->entityManager->flush();
}
开发者ID:3lolo,项目名称:lr_app,代码行数:29,代码来源:DoctrineORMAdapterTest.php
示例7: execute
/**
* do the thing here.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$driver = new DoctrineAdapter();
$driver->init();
$em = $driver->getManager();
$schema = new SchemaTool($em);
$models = [];
$model_name = $input->getArgument('model_name');
$full_name = Config::getInstance()->get('root-namespace') . '\\Models' . '\\' . $model_name . 'Model';
$schemaManager = $em->getConnection()->getSchemaManager();
try {
$metadata = $em->getClassMetadata($full_name);
$table_name = $metadata->getTableName();
if ($schemaManager->tablesExist([$table_name]) == true) {
$models[] = $metadata;
}
if (count($models) > 0) {
$schema->dropSchema($models);
} else {
$output->writeln('O model ' . $full_name . ' nao esta registrado no banco de dados.');
}
} catch (\Doctrine\ORM\Mapping\MappingException $e) {
$output->writeln('Erro encontrado:');
$output->writeln($e->getMessage());
return;
}
$output->writeln('Tabela ' . $table_name . ' removida com sucesso.');
}
开发者ID:anna-framework,项目名称:anna,代码行数:31,代码来源:DbDropTableCommand.php
示例8: executeSchemaCommand
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{
// Defining if update is complete or not (--complete not defined means $saveMode = true)
$saveMode = $input->getOption('complete') !== true;
if ($input->getOption('dump-sql') === true) {
$sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
$output->write(implode(';' . PHP_EOL, $sqls) . PHP_EOL);
} else {
if ($input->getOption('force') === true) {
$output->write('Updating database schema...' . PHP_EOL);
$schemaTool->updateSchema($metadatas, $saveMode);
$output->write('Database schema updated successfully!' . PHP_EOL);
} else {
$output->write('ATTENTION: This operation should not be executed in a production environment.' . PHP_EOL);
$output->write('Use the incremental update to detect changes during development and use' . PHP_EOL);
$output->write('this SQL DDL to manually update your database in production.' . PHP_EOL . PHP_EOL);
$sqls = $schemaTool->getUpdateSchemaSql($metadatas, $saveMode);
if (count($sqls)) {
$output->write('Schema-Tool would execute ' . count($sqls) . ' queries to update the database.' . PHP_EOL);
$output->write('Please run the operation with --force to execute these queries or use --dump-sql to see them.' . PHP_EOL);
} else {
$output->write('Nothing to update. The database is in sync with the current entity metadata.' . PHP_EOL);
}
}
}
}
开发者ID:halljb57,项目名称:flextrine,代码行数:26,代码来源:UpdateCommand.php
示例9: createSchemaTool
/**
* @param EntityManager $em
* @return SchemaTool
*/
private function createSchemaTool(EntityManager $em)
{
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase();
$schemaTool->createSchema($em->getMetadataFactory()->getAllMetadata());
return $schemaTool;
}
开发者ID:cobase,项目名称:cobase,代码行数:11,代码来源:ServiceTestCase.php
示例10: updateDbSchema
/**
* Updates DB Schema. Changes from Diamante only will be applied for current schema. Other bundles updating skips
* @throws \Exception if there are no changes in entities
*/
protected function updateDbSchema()
{
/**
* @var $em \Doctrine\ORM\EntityManager
*/
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$event = $em->getEventManager();
$sm = $em->getConnection()->getSchemaManager();
$allMetadata = $em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($em);
$entitiesMetadata = array($em->getClassMetadata(\Diamante\DeskBundle\Entity\Branch::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\Ticket::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\Comment::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\Attachment::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\BranchEmailConfiguration::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\MessageReference::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\TicketHistory::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\WatcherList::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\TicketTimeline::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\Audit::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\AuditField::getClassName()), $em->getClassMetadata(\Diamante\DeskBundle\Entity\Article::getClassName()));
$event->disableListeners();
$currentSchema = $sm->createSchema();
$schemaFromMetadata = $schemaTool->getSchemaFromMetadata($allMetadata);
$entitiesSchema = $schemaTool->getSchemaFromMetadata($entitiesMetadata);
$entitiesTables = $entitiesSchema->getTables();
$entitiesTableName = array_keys($entitiesTables);
$currentDiamanteSchema = $this->getTargetSchema($currentSchema, $entitiesTableName);
$diamanteSchemaFromMetadata = $this->getTargetSchema($schemaFromMetadata, $entitiesTableName);
$comparator = new Comparator();
$diff = $comparator->compare($currentDiamanteSchema, $diamanteSchemaFromMetadata);
$toUpdate = $diff->toSql($em->getConnection()->getDatabasePlatform());
if (empty($toUpdate)) {
throw new \Exception('No new updates found. DiamanteDesk is up to date!');
}
$conn = $em->getConnection();
foreach ($toUpdate as $sql) {
$conn->executeQuery($sql);
}
}
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:34,代码来源:AbstractCommand.php
示例11: updateDbSchema
/**
* Updates DB Schema.
* @throws \Exception if there are no changes in entities
*/
protected function updateDbSchema()
{
/**
* @var $em \Doctrine\ORM\EntityManager
*/
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$event = $em->getEventManager();
$sm = $em->getConnection()->getSchemaManager();
$allMetadata = $em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($em);
$entitiesMetadata = array($em->getClassMetadata(ApiUser::getClassName()), $em->getClassMetadata(DiamanteUser::getClassName()));
$event->disableListeners();
$currentSchema = $sm->createSchema();
$schemaFromMetadata = $schemaTool->getSchemaFromMetadata($allMetadata);
$entitiesSchema = $schemaTool->getSchemaFromMetadata($entitiesMetadata);
$entitiesTables = $entitiesSchema->getTables();
$entitiesTableName = array_keys($entitiesTables);
$currentDiamanteSchema = $this->getTargetSchema($currentSchema, $entitiesTableName);
$diamanteSchemaFromMetadata = $this->getTargetSchema($schemaFromMetadata, $entitiesTableName);
$comparator = new Comparator();
$diff = $comparator->compare($currentDiamanteSchema, $diamanteSchemaFromMetadata);
$toUpdate = $diff->toSql($em->getConnection()->getDatabasePlatform());
if (empty($toUpdate)) {
throw new \Exception('No new updates found. Diamante Api Bundle is up to date!');
}
$conn = $em->getConnection();
foreach ($toUpdate as $sql) {
$conn->executeQuery($sql);
}
}
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:34,代码来源:SchemaCommand.php
示例12: prepareDatabase
private function prepareDatabase()
{
/** @var EntityManager $em */
$em = $this->registry->getManager();
$tool = new SchemaTool($em);
$tool->createSchema($em->getMetadataFactory()->getAllMetadata());
}
开发者ID:karol-wojcik,项目名称:serializer,代码行数:7,代码来源:IntegrationTest.php
示例13: createSchema
private function createSchema(ContainerInterface $container)
{
$entityManager = $container->get('doctrine.orm.entity_manager');
/** @var EntityManager $entityManager */
$schemaTool = new SchemaTool($entityManager);
$schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
}
开发者ID:TomasVotruba,项目名称:SymfonyBridge,代码行数:7,代码来源:SmokeTest.php
示例14: dropAndCreateSchema
private function dropAndCreateSchema()
{
$schemaTool = new SchemaTool($this->getEntityManager());
$metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();
$schemaTool->dropSchema($metadata);
$schemaTool->createSchema($metadata);
}
开发者ID:lzakrzewski,项目名称:tests-with-database-examples,代码行数:7,代码来源:EmptyDatabaseTest.php
示例15: createDoctrineSchema
/**
* Creates schema for doctrine entities
*
* @throws \Doctrine\ORM\Tools\ToolsException
*/
protected function createDoctrineSchema()
{
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
$tool = new SchemaTool($this->entityManager);
$tool->dropSchema($metadata);
$tool->createSchema($metadata);
}
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:12,代码来源:DatabaseSchemaCreator.php
示例16: testCreateReturnsRestServiceEntityWithControllerServiceNamePopulated
/**
* @see https://github.com/zfcampus/zf-apigility/issues/18
*/
public function testCreateReturnsRestServiceEntityWithControllerServiceNamePopulated()
{
$serviceManager = $this->getApplication()->getServiceManager();
$em = $serviceManager->get('doctrine.entitymanager.orm_default');
$tool = new SchemaTool($em);
$res = $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
// Create DB
$resourceDefinition = array("objectManager" => "doctrine.entitymanager.orm_default", "serviceName" => "Artist", "entityClass" => "Db\\Entity\\Artist", "routeIdentifierName" => "artist_id", "entityIdentifierName" => "id", "routeMatch" => "/db-test/artist");
// Verify ORM is working
$artist = new \Db\Entity\Artist();
$artist->setName('TestInsert');
$artist->setCreatedAt(new \Datetime());
$em->persist($artist);
$em->flush();
$found = $em->getRepository('Db\\Entity\\Artist')->find($artist->getId());
$this->assertInstanceOf('Db\\Entity\\Artist', $found);
$this->resource = $serviceManager->get('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceResource');
$this->resource->setModuleName('DbApi');
$entity = $this->resource->create($resourceDefinition);
$this->assertInstanceOf('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceEntity', $entity);
$controllerServiceName = $entity->controllerServiceName;
$this->assertNotEmpty($controllerServiceName);
$this->assertContains('DbApi\\V1\\Rest\\Artist\\Controller', $controllerServiceName);
// $serviceManager = ServiceManagerFactory::getServiceManager();
// $config = $serviceManager->get('Config');
// $routerConfig = isset($config['router']) ? $config['router'] : array();
// $router = HttpRouter::factory($routerConfig);
// $routeMatch = new RouteMatch(array('controller' => $controllerServiceName));
// $event = new MvcEvent();
// $event->setRouter($router);
// $event->setRouteMatch($routeMatch);
// $this->getRequest()->setMethod('GET');
$request = $this->getRequest();
$request->setMethod('GET');
$request->getHeaders()->addHeaders(array('Accept' => 'application/json'));
$x = $this->dispatch('/db-api/artist');
$this->resource->delete('DbApi\\V1\\Rest\\Artist\\Controller');
print_r($x);
return;
// $controller->setEvent($event);
// $controller->setServiceLocator($serviceManager);
// $routeMatch = new RouteMatch(array('controller' => $controllerServiceName));
// print_r($config);
// print_r(get_class_methods($router));
$this->resource->delete('DbApi\\V1\\Rest\\Artist\\Controller');
return;
// $controller = new $controllerServiceName;
// $request = new Request();
$query = array();
$query[] = array('type' => 'eq', 'field' => 'id', 'value' => $found->getId());
// Fetch test runs
$routeMatch->setParam('action', 'index');
$result = $controller->dispatch($this->request);
$response = $controller->getResponse();
// $this->assertEquals(200, $response->getStatusCode());
$hal = $response->getBody();
$renderer = $this->getServiceLocator()->get('ZF\\Hal\\JsonRenderer');
$data = json_decode($renderer->render($hal), true);
print_r($data);
}
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:63,代码来源:DoctrineRestServiceResourceTest.php
示例17: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$configuration = $this->_getMigrationConfiguration($input, $output);
$em = $this->getHelper('em')->getEntityManager();
$conn = $em->getConnection();
$platform = $conn->getDatabasePlatform();
$metadata = $em->getMetadataFactory()->getAllMetadata();
if (empty($metadata)) {
$output->writeln('No mapping information to process.', 'ERROR');
return;
}
$tool = new SchemaTool($em);
$fromSchema = $conn->getSchemaManager()->createSchema();
$toSchema = $tool->getSchemaFromMetadata($metadata);
$up = $this->_buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform));
$down = $this->_buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform));
if ( ! $up && ! $down) {
$output->writeln('No changes detected in your mapping information.', 'ERROR');
return;
}
$version = date('YmdHis');
$path = $this->_generateMigration($configuration, $input, $version, $up, $down);
$output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));
}
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:31,代码来源:DiffCommand.php
示例18: execute
public function execute()
{
$d = $this->factory()->appDoctrine();
$this->app->dataStorage->clearStorage('CyantreeDoctrineModule/Proxies');
$this->app->cacheStorage->clearStorage('CyantreeDoctrineModule');
$tool = new SchemaTool($d);
$queries = $tool->getUpdateSchemaSql($d->getMetadataFactory()->getAllMetadata());
if ($queries) {
$hash = '';
foreach ($queries as $query) {
$hash = md5($hash . $query);
}
$code = substr($hash, 0, 8);
if ($transferredCode = $this->request->args->get('code')) {
if ($transferredCode == $code) {
$tool->updateSchema($d->getMetadataFactory()->getAllMetadata());
$this->result->showSuccess('Schema has been updated.');
return;
} else {
$this->result->showError('Passed invalid code.');
}
}
$this->result->showWarning('Schema is not up to date. The following queries would be executed:');
foreach ($queries as $query) {
$this->result->showInfo($query);
}
$this->result->showWarning("Execute with -code={$code} to update the database schema.");
} else {
$this->result->showSuccess('Schema is up to date.');
}
}
开发者ID:cyantree,项目名称:grout-project,代码行数:31,代码来源:UpdateDatabaseSchemaCommand.php
示例19: setUp
protected function setUp()
{
parent::setUp();
if (!class_exists('Symfony\\Component\\Form\\Form')) {
$this->markTestSkipped('The "Form" component is not available');
}
if (!class_exists('Doctrine\\DBAL\\Platforms\\MySqlPlatform')) {
$this->markTestSkipped('Doctrine DBAL is not available.');
}
if (!class_exists('Doctrine\\Common\\Version')) {
$this->markTestSkipped('Doctrine Common is not available.');
}
if (!class_exists('Doctrine\\ORM\\EntityManager')) {
$this->markTestSkipped('Doctrine ORM is not available.');
}
$this->em = DoctrineTestHelper::createTestEntityManager();
$this->emRegistry = $this->createRegistryMock('default', $this->em);
$this->items = array();
$schemaTool = new SchemaTool($this->em);
$classes = array($this->em->getClassMetadata(self::SINGLE_INT_ID_CLASS));
try {
$schemaTool->dropSchema($classes);
} catch (\Exception $e) {
}
try {
$schemaTool->createSchema($classes);
} catch (\Exception $e) {
}
$this->createEntities();
$this->factory = Forms::createFormFactoryBuilder()->addExtensions($this->getExtensions())->addTypeExtension(new ChoiceSelect2TypeExtension($this->dispatcher, $this->requestStack, $this->router, $this->getExtensionTypeName(), 10))->addType(new EntityType($this->emRegistry))->addTypeExtension(new EntitySelect2TypeExtension())->getFormFactory();
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
}
开发者ID:mcdir,项目名称:SonatraFormExtensionsBundle,代码行数:32,代码来源:EntitySelect2TypeExtensionTest.php
示例20: execute
/**
* do the thing here.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$driver = new DoctrineAdapter();
$driver->init();
$em = $driver->getManager();
$classes = loadAppModels();
$schema = new SchemaTool($em);
$models = [];
try {
$schemaManager = $em->getConnection()->getSchemaManager();
foreach ($classes as $class) {
$metadata = $em->getClassMetadata($class);
$table_name = $metadata->getTableName();
if ($schemaManager->tablesExist([$table_name]) == true) {
array_push($models, $metadata);
}
}
if (count($models) > 0) {
$schema->dropSchema($models);
} else {
$output->writeln('Nao ha models exportados para o banco de dados');
}
} catch (\Doctrine\ORM\Mapping\MappingException $e) {
$output->writeln('Erro encontrado:');
$output->writeln($e->getMessage());
return;
}
$output->writeln('Tabelas removidas com sucesso.');
}
开发者ID:anna-framework,项目名称:anna,代码行数:32,代码来源:DbDropTablesCommand.php
注:本文中的Doctrine\ORM\Tools\SchemaTool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论