content_packager-8.x-1.x-dev/content_packager.install
content_packager.install
<?php /** * @file * Install, update and uninstall functions for the content packager module. */ use Drupal\Core\Database\Database; /** * Implements hook_uninstall(). */ function content_packager_uninstall() { $scheme = \Drupal::config('content_packager.settings')->get('scheme'); \Drupal::service('file_system')->deleteRecursive($scheme . '/content_packager'); } /** * Implements hook_schema(). */ function content_packager_schema() { $schema['content_packager_processed'] = [ 'description' => 'Stores processed entity information to avoid potentially circular entity references in a View.', 'fields' => [ 'entitytype' => [ 'description' => 'The name of the entity.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', ], 'eid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The entity ID.", ], ], 'primary key' => ['entitytype', 'eid'], ]; return $schema; } /** * Add db table to avoid circular refs being packed, remove batch_size config. */ function content_packager_update_8101() { $spec = [ 'description' => 'Stores processed entity information to avoid potentially circular entity references in a View.', 'fields' => [ 'entitytype' => [ 'description' => 'The name of the entity.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', ], 'eid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The entity ID.", ], ], 'primary key' => ['entitytype', 'eid'], ]; $schema = Database::getConnection()->schema(); $schema->createTable('content_packager_processed', $spec); $config = \Drupal::config('content_packager.settings'); $config->clear('batch_size'); $config->save(TRUE); } /** * Add a jsonapi_uri setting to configuration. */ function content_packager_update_8102() { $config_factory = \Drupal::configFactory(); $config = $config_factory->getEditable('content_packager.settings'); $config->set('jsonapi_uri', '/jsonapi/node/article'); $config->save(TRUE); }