Skip to content
Snippets Groups Projects
Unverified Commit d346b0b1 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

Issue #3264767 by heddn, Matroskeen: Support Drupal core 10 + PHP 8.1

parent 2b4ecaae
No related branches found
No related tags found
1 merge request!8Issue #3229479: Entity_lookup taxonomy_term restricted by VID
Showing
with 121 additions and 133 deletions
......@@ -30,14 +30,8 @@
"config": {
"preferred-install": "dist"
},
"require-dev": {
"drush/drush": "^10"
},
"extra": {
"drush": {
"services": {
"drush.services.yml": "^9 || ^10"
}
}
"require": {
"php": ">=7.4",
"drupal/core": ">=9.1"
}
}
......@@ -2,7 +2,7 @@ type: module
name: Migrate Example
description: 'Examples of how Drupal 8+ migration compares to previous versions.'
package: Examples
core_version_requirement: ^8.8 || ^9
core_version_requirement: '>=9.1'
dependencies:
- drupal:migrate
- migrate_plus:migrate_example_setup
......
......@@ -2,7 +2,7 @@ type: module
name: Migrate Example Setup
description: 'Separate site configuration for the example from the actual migration.'
package: Migration
core_version_requirement: ^8.8 || ^9
core_version_requirement: '>=9.1'
hidden: true
dependencies:
- drupal:comment
......
<?php
declare(strict_types = 1);
/**
* @file
* Install file for migrate example module.
......@@ -12,7 +14,8 @@
/**
* Implements hook_schema().
*/
function migrate_example_setup_schema() {
function migrate_example_setup_schema(): array {
$schema = [];
$schema['migrate_example_beer_account'] = migrate_example_beer_schema_account();
$schema['migrate_example_beer_node'] = migrate_example_beer_schema_node();
$schema['migrate_example_beer_comment'] = migrate_example_beer_schema_comment();
......@@ -25,7 +28,7 @@ function migrate_example_setup_schema() {
/**
* Implements hook_install().
*/
function migrate_example_setup_install() {
function migrate_example_setup_install(): void {
// Populate our tables.
migrate_example_beer_data_account();
migrate_example_beer_data_node();
......@@ -37,10 +40,9 @@ function migrate_example_setup_install() {
/**
* The hook_schema definition for node.
*
* @return array
* The schema definition.
*/
function migrate_example_beer_schema_node() {
function migrate_example_beer_schema_node(): array {
return [
'description' => 'Beers of the world.',
'fields' => [
......@@ -109,10 +111,9 @@ function migrate_example_beer_schema_node() {
/**
* The hook_schema definition for topic.
*
* @return array
* The schema definition.
*/
function migrate_example_beer_schema_topic() {
function migrate_example_beer_schema_topic(): array {
return [
'description' => 'Categories',
'fields' => [
......@@ -152,10 +153,9 @@ function migrate_example_beer_schema_topic() {
/**
* The hook_schema definition for topic node.
*
* @return array
* The schema definition.
*/
function migrate_example_beer_schema_topic_node() {
function migrate_example_beer_schema_topic_node(): array {
return [
'description' => 'Beers topic pairs.',
'fields' => [
......@@ -178,10 +178,9 @@ function migrate_example_beer_schema_topic_node() {
/**
* The hook_schema definition for comment.
*
* @return array
* The schema definition.
*/
function migrate_example_beer_schema_comment() {
function migrate_example_beer_schema_comment(): array {
return [
'description' => 'Beers comments.',
'fields' => [
......@@ -237,10 +236,9 @@ function migrate_example_beer_schema_comment() {
/**
* The hook_schema definition for account.
*
* @return array
* The schema definition.
*/
function migrate_example_beer_schema_account() {
function migrate_example_beer_schema_account(): array {
return [
'description' => 'Beers accounts.',
'fields' => [
......@@ -303,7 +301,7 @@ function migrate_example_beer_schema_account() {
/**
* Populate node table.
*/
function migrate_example_beer_data_node() {
function migrate_example_beer_data_node(): void {
$fields = [
'bid',
'name',
......@@ -372,7 +370,7 @@ function migrate_example_beer_data_node() {
*
* @todo Duplicate email also.
*/
function migrate_example_beer_data_account() {
function migrate_example_beer_data_account(): void {
$fields = [
'status',
'registered',
......@@ -436,7 +434,7 @@ function migrate_example_beer_data_account() {
/**
* Populate comment table.
*/
function migrate_example_beer_data_comment() {
function migrate_example_beer_data_comment(): void {
$fields = ['bid', 'cid_parent', 'subject', 'body', 'name', 'mail', 'aid'];
$query = \Drupal::database()->insert('migrate_example_beer_comment')
->fields($fields);
......@@ -464,7 +462,7 @@ function migrate_example_beer_data_comment() {
/**
* Populate topic table.
*/
function migrate_example_beer_data_topic() {
function migrate_example_beer_data_topic(): void {
$fields = ['style', 'details', 'style_parent', 'region', 'hoppiness'];
$query = \Drupal::database()->insert('migrate_example_beer_topic')
->fields($fields);
......@@ -488,7 +486,7 @@ function migrate_example_beer_data_topic() {
/**
* Populate topic node table.
*/
function migrate_example_beer_data_topic_node() {
function migrate_example_beer_data_topic_node(): void {
$fields = ['bid', 'style'];
$query = \Drupal::database()->insert('migrate_example_beer_topic_node')
->fields($fields);
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example\Plugin\migrate\source;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
......@@ -11,12 +14,12 @@ use Drupal\migrate\Plugin\migrate\source\SqlBase;
* id = "beer_comment"
* )
*/
class BeerComment extends SqlBase {
final class BeerComment extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
public function query(): SelectInterface {
$fields = [
'cid',
'cid_parent',
......@@ -27,17 +30,16 @@ class BeerComment extends SqlBase {
'bid',
'subject',
];
$query = $this->select('migrate_example_beer_comment', 'mec')
return $this->select('migrate_example_beer_comment', 'mec')
->fields('mec', $fields)
->orderBy('cid_parent', 'ASC');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
public function fields(): array {
return [
'cid' => $this->t('Comment ID'),
'cid_parent' => $this->t('Parent comment ID in case of comment replies'),
'name' => $this->t('Comment name (if anon)'),
......@@ -46,14 +48,12 @@ class BeerComment extends SqlBase {
'bid' => $this->t('Beer ID that is being commented upon'),
'subject' => $this->t('Comment subject'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
public function getIds(): array {
return [
'cid' => [
'type' => 'integer',
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example\Plugin\migrate\source;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;
......@@ -12,12 +15,12 @@ use Drupal\migrate\Row;
* id = "beer_node"
* )
*/
class BeerNode extends SqlBase {
final class BeerNode extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
public function query(): SelectInterface {
// An important point to note is that your query *must* return a single row
// for each item to be imported. Here we might be tempted to add a join to
// migrate_example_beer_topic_node in our query, to pull in the
......@@ -39,16 +42,15 @@ class BeerNode extends SqlBase {
'image_title',
'image_description',
];
$query = $this->select('migrate_example_beer_node', 'b')
return $this->select('migrate_example_beer_node', 'b')
->fields('b', $fields);
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
public function fields(): array {
return [
'bid' => $this->t('Beer ID'),
'name' => $this->t('Name of beer'),
'body' => $this->t('Full description of the beer'),
......@@ -64,14 +66,12 @@ class BeerNode extends SqlBase {
// are available for mapping after prepareRow() is called.
'terms' => $this->t('Applicable styles'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
public function getIds(): array {
return [
'bid' => [
'type' => 'integer',
......@@ -83,7 +83,7 @@ class BeerNode extends SqlBase {
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
public function prepareRow(Row $row): bool {
// As explained above, we need to pull the style relationships into our
// source row here, as an array of 'style' values (the unique ID for
// the beer_term migration).
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example\Plugin\migrate\source;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
......@@ -20,12 +23,12 @@ use Drupal\migrate\Plugin\migrate\source\SqlBase;
* id = "beer_term"
* )
*/
class BeerTerm extends SqlBase {
final class BeerTerm extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
public function query(): SelectInterface {
// The most important part of a SQL source plugin is the SQL query to
// retrieve the data to be imported. Note that the query is not executed
// here - the migration process will control execution of the query. Also
......@@ -42,12 +45,12 @@ class BeerTerm extends SqlBase {
/**
* {@inheritdoc}
*/
public function fields() {
public function fields(): array {
// This method simply documents the available source fields provided by the
// source plugin, for use by front-end tools. It returns an array keyed by
// field/column name, with the value being a translated string explaining
// to humans what the field represents.
$fields = [
return [
'style' => $this->t('Beer style'),
'details' => $this->t('Style details'),
'style_parent' => $this->t('Parent style'),
......@@ -56,14 +59,12 @@ class BeerTerm extends SqlBase {
'region' => $this->t('Region the style is associated with'),
'hoppiness' => $this->t('Hoppiness of the style'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
public function getIds(): array {
// This method indicates what field(s) from the source row uniquely identify
// that source row, and what their types are. This is critical information
// for managing the migration. The keys of the returned array are the field
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example\Plugin\migrate\source;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;
......@@ -12,12 +15,12 @@ use Drupal\migrate\Row;
* id = "beer_user"
* )
*/
class BeerUser extends SqlBase {
final class BeerUser extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
public function query(): SelectInterface {
$fields = [
'aid',
'status',
......@@ -36,8 +39,8 @@ class BeerUser extends SqlBase {
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
public function fields(): array {
return [
'aid' => $this->t('Account ID'),
'status' => $this->t('Blocked/Allowed'),
'registered' => $this->t('Registered date'),
......@@ -48,14 +51,12 @@ class BeerUser extends SqlBase {
'sex' => $this->t('Gender'),
'beers' => $this->t('Favorite beers, pipe-separated'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
public function getIds(): array {
return [
'aid' => [
'type' => 'integer',
......@@ -67,7 +68,7 @@ class BeerUser extends SqlBase {
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
public function prepareRow(Row $row): bool {
// A prepareRow() is the most common place to perform custom run-time
// processing that isn't handled by an existing process plugin. It is called
// when the raw data has been pulled from the source, and provides the
......
<?php
declare(strict_types = 1);
namespace Drupal\Tests\migrate_example\Kernel;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
......@@ -9,7 +11,7 @@ use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
*
* @group migrate_plus
*/
class MigrateExampleTest extends MigrateDrupalTestBase {
final class MigrateExampleTest extends MigrateDrupalTestBase {
/**
* {@inheritdoc}
......@@ -55,7 +57,7 @@ class MigrateExampleTest extends MigrateDrupalTestBase {
/**
* Tests the results of "Beer" example migration.
*/
public function testBeerMigration() {
public function testBeerMigration(): void {
$users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple();
// There are 4 users created in beer_user migration and 1 stub entity
// created during beer_node migration.
......
......@@ -2,7 +2,7 @@ type: module
name: Migrate Example (Advanced)
description: 'Specialized examples of Drupal 8+ migration.'
package: Examples
core_version_requirement: ^8.8 || ^9
core_version_requirement: '>=9.1'
dependencies:
- drupal:migrate
- migrate_plus:migrate_example_advanced_setup
......
<?php
declare(strict_types = 1);
/**
* @file
* Install, update and uninstall functions for migrate_example_advanced module.
......@@ -15,7 +17,7 @@ use Drupal\migrate_plus\Entity\Migration;
* use. So, in the .yml files we provide the REST resources relative to the
* site root and here rewrite them to fully-qualified paths.
*/
function migrate_example_advanced_install() {
function migrate_example_advanced_install(): void {
/** @var \Drupal\migrate_plus\Entity\MigrationInterface $wine_role_xml_migration */
$wine_role_xml_migration = Migration::load('wine_role_xml');
if ($wine_role_xml_migration) {
......
......@@ -2,7 +2,7 @@ type: module
name: Migrate Advanced Example Setup
description: 'Separate site configuration for the example from the actual migration.'
package: Migration
core_version_requirement: ^8.8 || ^9
core_version_requirement: '>=9.1'
hidden: true
dependencies:
- drupal:comment
......
......@@ -12,7 +12,8 @@
/**
* Implements hook_schema().
*/
function migrate_example_advanced_setup_schema() {
function migrate_example_advanced_setup_schema(): array {
$schema = [];
$schema['migrate_example_advanced_account'] = migrate_example_advanced_schema_account();
$schema['migrate_example_advanced_account_updates'] = migrate_example_advanced_schema_account_updates();
$schema['migrate_example_advanced_categories'] = migrate_example_advanced_schema_categories();
......@@ -36,7 +37,7 @@ function migrate_example_advanced_setup_schema() {
/**
* Implements hook_install().
*/
function migrate_example_advanced_setup_install() {
function migrate_example_advanced_setup_install(): void {
// Populate our tables.
migrate_example_advanced_data_account();
migrate_example_advanced_data_account_updates();
......@@ -61,7 +62,7 @@ function migrate_example_advanced_setup_install() {
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_wine() {
function migrate_example_advanced_schema_wine(): array {
return [
'description' => 'Wines of the world',
'fields' => [
......@@ -135,7 +136,7 @@ function migrate_example_advanced_schema_wine() {
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_updates() {
function migrate_example_advanced_schema_updates(): array {
return [
'description' => 'Updated wine ratings',
'fields' => [
......@@ -162,7 +163,7 @@ function migrate_example_advanced_schema_updates() {
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_producer() {
function migrate_example_advanced_schema_producer(): array {
return [
'description' => 'Wine producers of the world',
'fields' => [
......@@ -203,10 +204,9 @@ function migrate_example_advanced_schema_producer() {
/**
* The hook_schema definition for categories.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_categories() {
function migrate_example_advanced_schema_categories(): array {
return [
'description' => 'Categories',
'fields' => [
......@@ -252,10 +252,9 @@ function migrate_example_advanced_schema_categories() {
/**
* The hook_schema definition for vintages.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_vintages() {
function migrate_example_advanced_schema_vintages(): array {
return [
'description' => 'Wine vintages',
'fields' => [
......@@ -278,10 +277,9 @@ function migrate_example_advanced_schema_vintages() {
/**
* The hook_schema definition for variety updates.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_variety_updates() {
function migrate_example_advanced_schema_variety_updates(): array {
return [
'description' => 'Variety updates',
'fields' => [
......@@ -304,10 +302,9 @@ function migrate_example_advanced_schema_variety_updates() {
/**
* The hook_schema definition for category wine.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_category_wine() {
function migrate_example_advanced_schema_category_wine(): array {
return [
'description' => 'Wine category assignments',
'fields' => [
......@@ -330,10 +327,9 @@ function migrate_example_advanced_schema_category_wine() {
/**
* The hook_schema definition for category producer.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_category_producer() {
function migrate_example_advanced_schema_category_producer(): array {
return [
'description' => 'Producer category assignments',
'fields' => [
......@@ -356,10 +352,9 @@ function migrate_example_advanced_schema_category_producer() {
/**
* The hook_schema definition for comment.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_comment() {
function migrate_example_advanced_schema_comment(): array {
return [
'description' => 'Wine comments',
'fields' => [
......@@ -443,10 +438,9 @@ function migrate_example_advanced_schema_comment() {
/**
* The hook_schema definition for comment updates.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_comment_updates() {
function migrate_example_advanced_schema_comment_updates(): array {
return [
'description' => 'Wine comment updates',
'fields' => [
......@@ -470,10 +464,9 @@ function migrate_example_advanced_schema_comment_updates() {
/**
* The hook_schema definition for account.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_account() {
function migrate_example_advanced_schema_account(): array {
return [
'description' => 'Wine accounts.',
'fields' => [
......@@ -561,10 +554,9 @@ function migrate_example_advanced_schema_account() {
/**
* The hook_schema definition for account updates.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_account_updates() {
function migrate_example_advanced_schema_account_updates(): array {
return [
'description' => 'Wine account updates',
'fields' => [
......@@ -587,10 +579,9 @@ function migrate_example_advanced_schema_account_updates() {
/**
* The hook_schema definition for blobs.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_blobs() {
function migrate_example_advanced_schema_blobs(): array {
return [
'description' => 'Wine blobs to be migrated to file entities',
'fields' => [
......@@ -613,10 +604,9 @@ function migrate_example_advanced_schema_blobs() {
/**
* The hook_schema definition for files.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_files() {
function migrate_example_advanced_schema_files(): array {
return [
'description' => 'Wine and account files',
'fields' => [
......@@ -658,10 +648,9 @@ function migrate_example_advanced_schema_files() {
/**
* The hook_schema definition for table source.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_table_source() {
function migrate_example_advanced_schema_table_source(): array {
return [
'description' => 'Source data to go into a custom Drupal table',
'fields' => [
......@@ -691,10 +680,9 @@ function migrate_example_advanced_schema_table_source() {
/**
* The hook_schema definition for table destination.
*
* @return array
* The schema definition.
*/
function migrate_example_advanced_schema_table_dest() {
function migrate_example_advanced_schema_table_dest(): array {
return [
'description' => 'Custom Drupal table to receive source data directly',
'fields' => [
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example_advanced_setup\Plugin\rest\resource;
use Drupal\rest\Plugin\ResourceBase;
......@@ -16,27 +18,25 @@ use Drupal\rest\ResourceResponse;
* }
* )
*/
class PositionResource extends ResourceBase {
final class PositionResource extends ResourceBase {
/**
* Responds to GET requests.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the position data.
*/
public function get() {
public function get(): ResourceResponse {
$position1 = ['sourceid' => 'wine_taster', 'name' => 'Wine Taster'];
$position2 = ['sourceid' => 'vintner', 'name' => 'Vintner'];
$data = ['position' => [$position1, $position2]];
$response = new ResourceResponse($data, 200);
return $response;
return new ResourceResponse($data, 200);
}
/**
* {@inheritdoc}
*/
public function permissions() {
public function permissions(): array {
// Remove permissions so the resource is available to all.
return [];
}
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example_advanced_setup\Plugin\rest\resource;
use Drupal\rest\Plugin\ResourceBase;
......@@ -16,18 +18,17 @@ use Drupal\rest\ResourceResponse;
* }
* )
*/
class VarietyItems extends ResourceBase {
final class VarietyItems extends ResourceBase {
/**
* Responds to GET requests.
*
* @param string $variety
* @param string|null $variety
* Machine name of the variety to retrieve.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the requested variety data.
*/
public function get($variety = NULL) {
public function get(?string $variety = NULL): ResourceResponse {
$varieties = [
'retsina' => [
'name' => 'Retsina',
......@@ -61,14 +62,13 @@ class VarietyItems extends ResourceBase {
$data = [];
}
$response = new ResourceResponse($data, 200);
return $response;
return new ResourceResponse($data, 200);
}
/**
* {@inheritdoc}
*/
public function permissions() {
public function permissions(): array {
// Remove permissions so the resource is available to all.
return [];
}
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example_advanced_setup\Plugin\rest\resource;
use Drupal\rest\Plugin\ResourceBase;
......@@ -16,25 +18,24 @@ use Drupal\rest\ResourceResponse;
* }
* )
*/
class VarietyList extends ResourceBase {
final class VarietyList extends ResourceBase {
/**
* Responds to GET requests.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the requested variety data.
*/
public function get() {
public function get(): ResourceResponse {
$data = [];
$data['items'] = ['retsina', 'trebbiano', 'valpolicella', 'bardolino'];
$response = new ResourceResponse($data, 200);
return $response;
return new ResourceResponse($data, 200);
}
/**
* {@inheritdoc}
*/
public function permissions() {
public function permissions(): array {
// Remove permissions so the resource is available to all.
return [];
}
......
......@@ -21,13 +21,12 @@ class VarietyMultiFiles extends ResourceBase {
/**
* Responds to GET requests.
*
* @param string $type
* @param string|null $type
* 'red', 'white', or NULL to return all varieties.
*
* @return \Drupal\rest\ResourceResponse
* The response containing the requested variety data.
*/
public function get($type = NULL) {
public function get(?string $type = NULL): ResourceResponse {
$data = [];
if (strtolower($type) != 'white') {
$data['variety'][] = [
......@@ -72,14 +71,13 @@ class VarietyMultiFiles extends ResourceBase {
];
}
$response = new ResourceResponse($data, 200);
return $response;
return new ResourceResponse($data, 200);
}
/**
* {@inheritdoc}
*/
public function permissions() {
public function permissions(): array {
// Remove permissions so the resource is available to all.
return [];
}
......
<?php
declare(strict_types = 1);
namespace Drupal\migrate_example_advanced\Plugin\migrate\source;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
......@@ -11,12 +14,12 @@ use Drupal\migrate\Plugin\migrate\source\SqlBase;
* id = "wine_term"
* )
*/
class WineTerm extends SqlBase {
final class WineTerm extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
public function query(): SelectInterface {
$fields = [
'categoryid',
'type',
......@@ -34,8 +37,8 @@ class WineTerm extends SqlBase {
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
public function fields(): array {
return [
'categoryid' => $this->t('Unique ID of the category'),
'type' => $this->t('Category type corresponding to Drupal vocabularies'),
'name' => $this->t('Category name'),
......@@ -43,14 +46,12 @@ class WineTerm extends SqlBase {
'category_parent' => $this->t('ID of the parent category'),
'ordering' => $this->t('Order in which to display this category'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
public function getIds(): array {
return ['categoryid' => ['type' => 'integer']];
}
......
......@@ -2,7 +2,7 @@ type: module
name: Migrate JSON Example
description: 'Simple JSON Migration example'
package: Examples
core_version_requirement: ^8.8 || ^9
core_version_requirement: '>=9.1'
dependencies:
- drupal:migrate
- migrate_plus:migrate_plus
<?php
declare(strict_types = 1);
/**
* @file
* Install, update, and uninstall functions for migrate_json_example.
......@@ -10,13 +12,13 @@ use Drupal\Core\File\FileSystemInterface;
/**
* Copies the example file to the sites/default/files folder.
*/
function migrate_json_example_install() {
function migrate_json_example_install(): void {
// Create the example file directory and ensure it's writable.
$directory = \Drupal::config('system.file')->get('default_scheme') . '://migrate_json_example';
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
// Copy the example file to example directory.
$module_path = drupal_get_path('module', 'migrate_json_example');
$module_path = \Drupal::service('extension.list.module')->getPath('migrate_json_example');
$file_source = $module_path . '/artifacts/products.json';
\Drupal::service('file_system')->copy($file_source, $directory . '/products.json', FileSystemInterface::EXISTS_REPLACE);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment