当前位置: 首页>>代码示例>>PHP>>正文


PHP drupal_get_module_schema函数代码示例

本文整理汇总了PHP中drupal_get_module_schema函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_get_module_schema函数的具体用法?PHP drupal_get_module_schema怎么用?PHP drupal_get_module_schema使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drupal_get_module_schema函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDefaultInsertWithFields

 /**
  * Tests that we can insert fields with values and defaults in the same query.
  */
 function testDefaultInsertWithFields()
 {
     $query = db_insert('test')->fields(array('name' => 'Bob'))->useDefaults(array('job'));
     $id = $query->execute();
     $schema = drupal_get_module_schema('database_test', 'test');
     $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
     $this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:11,代码来源:InsertDefaultsTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Drupal 8.0.x needs the router table installed which is done automatically
     // in Drupal 8.1.x. Remove this once Drupal 8.0.x is unsupported.
     if (!empty(drupal_get_module_schema('system', 'router'))) {
         $this->installSchema('system', ['router']);
         $this->container->get('router.builder')->rebuild();
     }
 }
开发者ID:Progressable,项目名称:openway8,代码行数:13,代码来源:RedirectEventSubscriberTest.php

示例3: assertModuleTablesDoNotExist

 /**
  * Assert that none of the tables defined in a module's hook_schema() exist.
  *
  * @param $module
  *   The name of the module.
  */
 function assertModuleTablesDoNotExist($module)
 {
     $tables = array_keys(drupal_get_module_schema($module));
     $tables_exist = FALSE;
     foreach ($tables as $table) {
         if (db_table_exists($table)) {
             $tables_exist = TRUE;
         }
     }
     return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', array('@module' => $module)));
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:17,代码来源:ModuleTestBase.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installConfig(['system']);
     $this->installConfig(['field']);
     $this->installConfig(['node']);
     $this->installSchema('system', ['sequences']);
     // Drupal 8.0.x needs the router table installed which is done automatically
     // in Drupal 8.1.x. Remove this once Drupal 8.0.x is unsupported.
     if (!empty(drupal_get_module_schema('system', 'router'))) {
         $this->installSchema('system', ['router']);
     }
     $this->installEntitySchema('user');
     $this->installEntitySchema('node');
     // Make sure that the node routes get picked when used during rendering.
     $this->container->get('router.builder')->rebuild();
 }
开发者ID:Progressable,项目名称:openway8,代码行数:20,代码来源:EntityViewTest.php

示例5: installSchema

 /**
  * Installs a specific table from a module schema definition.
  *
  * @param string $module
  *   The name of the module that defines the table's schema.
  * @param string|array $tables
  *   The name or an array of the names of the tables to install.
  *
  * @throws \RuntimeException
  *   Thrown when $module is not enabled or when the table schema cannot be
  *   found in the module specified.
  */
 protected function installSchema($module, $tables)
 {
     // drupal_get_module_schema() is technically able to install a schema
     // of a non-enabled module, but its ability to load the module's .install
     // file depends on many other factors. To prevent differences in test
     // behavior and non-reproducible test failures, we only allow the schema of
     // explicitly loaded/enabled modules to be installed.
     if (!$this->container->get('module_handler')->moduleExists($module)) {
         throw new \RuntimeException("'{$module}' module is not enabled");
     }
     $tables = (array) $tables;
     foreach ($tables as $table) {
         $schema = drupal_get_module_schema($module, $table);
         if (empty($schema)) {
             throw new \RuntimeException("Unknown '{$table}' table schema in '{$module}' module.");
         }
         $this->container->get('database')->schema()->createTable($table, $schema);
     }
     $this->pass(format_string('Installed %module tables: %tables.', array('%tables' => '{' . implode('}, {', $tables) . '}', '%module' => $module)));
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:32,代码来源:KernelTestBase.php

示例6: installSchema

 /**
  * Installs database tables from a module schema definition.
  *
  * @param string $module
  *   The name of the module that defines the table's schema.
  * @param string|array $tables
  *   The name or an array of the names of the tables to install.
  *
  * @throws \LogicException
  *   If $module is not enabled or the table schema cannot be found.
  */
 protected function installSchema($module, $tables)
 {
     // drupal_get_module_schema() is technically able to install a schema
     // of a non-enabled module, but its ability to load the module's .install
     // file depends on many other factors. To prevent differences in test
     // behavior and non-reproducible test failures, we only allow the schema of
     // explicitly loaded/enabled modules to be installed.
     if (!$this->container->get('module_handler')->moduleExists($module)) {
         throw new \LogicException("{$module} module is not enabled.");
     }
     $tables = (array) $tables;
     foreach ($tables as $table) {
         $schema = drupal_get_module_schema($module, $table);
         if (empty($schema)) {
             // BC layer to avoid some contrib tests to fail.
             // @todo Remove the BC layer before 8.1.x release.
             // @see https://www.drupal.org/node/2670360
             // @see https://www.drupal.org/node/2670454
             if ($module == 'system') {
                 continue;
             }
             throw new \LogicException("{$module} module does not define a schema for table '{$table}'.");
         }
         $this->container->get('database')->schema()->createTable($table, $schema);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:37,代码来源:KernelTestBase.php

示例7: clearTables

  /**
   * Batch method to truncate all remaining flag tables.
   */
  public static function clearTables(&$context) {
    // First, set the number of tables we'll truncate each invocation.

    $batch_size = 1;

    // Get the module schema.
    $schema = drupal_get_module_schema('flag');

    // If this is the first invocation, set our index and maximum.
    if (empty($context['sandbox'])) {
      $context['sandbox']['progress'] = 0;
      $context['sandbox']['max'] = count($schema);
    }

    // Get the database connection.
    $connection = Database::getConnection();

    // Truncate tables as needed in the batch.
    $tables = array_keys($schema);
    $progress = $context['sandbox']['progress'];
    for ($i = $progress; $i < $progress + $batch_size; $i++) {
      $table = $tables[$i];
      $connection->truncate($table)->execute();
    }

    // Increment our progress.
    $context['sandbox']['progress'] += $batch_size;

    // If we still have tables to truncate, set our progress percentage.
    if ($context['sandbox']['progress'] < $context['sandbox']['max']) {
      $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:36,代码来源:ClearAllForm.php

示例8: testInstallSchema

 /**
  * Tests expected behavior of installSchema().
  */
 function testInstallSchema()
 {
     $module = 'entity_test';
     $table = 'entity_test_example';
     // Verify that we can install a table from the module schema.
     $this->installSchema($module, $table);
     $this->assertTrue(db_table_exists($table), "'{$table}' database table found.");
     // Verify that the schema is known to Schema API.
     $schema = drupal_get_module_schema($module, $table);
     $this->assertTrue($schema, "'{$table}' table schema found.");
     // Verify that a unknown table from an enabled module throws an error.
     $table = 'unknown_entity_test_table';
     try {
         $this->installSchema($module, $table);
         $this->fail('Exception for non-retrievable schema found.');
     } catch (\Exception $e) {
         $this->pass('Exception for non-retrievable schema found.');
     }
     $this->assertFalse(db_table_exists($table), "'{$table}' database table not found.");
     $schema = drupal_get_module_schema($module, $table);
     $this->assertFalse($schema, "'{$table}' table schema not found.");
     // Verify that a table from a unknown module cannot be installed.
     $module = 'database_test';
     $table = 'test';
     try {
         $this->installSchema($module, $table);
         $this->fail('Exception for non-retrievable schema found.');
     } catch (\Exception $e) {
         $this->pass('Exception for non-retrievable schema found.');
     }
     $this->assertFalse(db_table_exists($table), "'{$table}' database table not found.");
     $schema = drupal_get_module_schema($module, $table);
     $this->assertTrue($schema, "'{$table}' table schema found.");
     // Verify that the same table can be installed after enabling the module.
     $this->enableModules(array($module));
     $this->installSchema($module, $table);
     $this->assertTrue(db_table_exists($table), "'{$table}' database table found.");
     $schema = drupal_get_module_schema($module, $table);
     $this->assertTrue($schema, "'{$table}' table schema found.");
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:43,代码来源:KernelTestBaseTest.php

示例9: installSchema

 /**
  * Installs database tables from a module schema definition.
  *
  * @param string $module
  *   The name of the module that defines the table's schema.
  * @param string|array $tables
  *   The name or an array of the names of the tables to install.
  *
  * @throws \LogicException
  *   If $module is not enabled or the table schema cannot be found.
  */
 protected function installSchema($module, $tables)
 {
     // drupal_get_module_schema() is technically able to install a schema
     // of a non-enabled module, but its ability to load the module's .install
     // file depends on many other factors. To prevent differences in test
     // behavior and non-reproducible test failures, we only allow the schema of
     // explicitly loaded/enabled modules to be installed.
     if (!$this->container->get('module_handler')->moduleExists($module)) {
         throw new \LogicException("{$module} module is not enabled.");
     }
     $tables = (array) $tables;
     foreach ($tables as $table) {
         $schema = drupal_get_module_schema($module, $table);
         if (empty($schema)) {
             throw new \LogicException("{$module} module does not define a schema for table '{$table}'.");
         }
         $this->container->get('database')->schema()->createTable($table, $schema);
     }
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:30,代码来源:KernelTestBase.php


注:本文中的drupal_get_module_schema函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。