├── README.md ├── composer.json ├── migrate_source_example.info.yml ├── migrate_source_example.module ├── migrate_source_example.services.yml ├── modules ├── migrate_source_example_csv │ ├── config │ │ └── install │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_author.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_book.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_book_translations.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_category.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_image.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_csv_user.yml │ │ │ └── migrate_plus.migration_group.migrate_source_example_csv.yml │ ├── migrate_source_example_csv.info.yml │ ├── migrate_source_example_csv.module │ ├── source │ │ ├── author.csv │ │ ├── book.csv │ │ ├── book_translations.csv │ │ ├── category.csv │ │ ├── image.csv │ │ └── user.csv │ └── src │ │ └── Plugin │ │ └── migrate │ │ └── source │ │ └── CSV.php ├── migrate_source_example_db │ ├── config │ │ └── install │ │ │ ├── migrate_plus.migration.migrate_source_example_db_author.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_db_book.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_db_category.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_db_image.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_db_user.yml │ │ │ └── migrate_plus.migration_group.migrate_source_example_db.yml │ ├── migrate_source_example_db.info.yml │ ├── migrate_source_example_db.install │ ├── migrate_source_example_db.module │ └── src │ │ └── Plugin │ │ └── migrate │ │ └── source │ │ ├── Book.php │ │ ├── Image.php │ │ ├── TaxonomyAttribute.php │ │ └── User.php ├── migrate_source_example_json │ ├── config │ │ └── install │ │ │ ├── migrate_plus.migration.migrate_source_example_json_author.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_json_book.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_json_category.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_json_image.yml │ │ │ ├── migrate_plus.migration.migrate_source_example_json_user.yml │ │ │ └── migrate_plus.migration_group.migrate_source_example_json.yml │ ├── migrate_source_example_json.info.yml │ ├── migrate_source_example_json.module │ ├── migrate_source_example_json.routing.yml │ ├── source │ │ ├── attributes.json │ │ ├── books.json │ │ ├── images.json │ │ └── users.json │ └── src │ │ └── Controller │ │ ├── AttributesMigrationController.php │ │ ├── BooksMigrationController.php │ │ ├── ImageMigrationController.php │ │ └── UserMigrationController.php ├── migrate_source_example_setup │ ├── config │ │ └── install │ │ │ ├── core.base_field_override.node.book.changed.yml │ │ │ ├── core.base_field_override.node.book.created.yml │ │ │ ├── core.base_field_override.node.book.path.yml │ │ │ ├── core.base_field_override.node.book.promote.yml │ │ │ ├── core.base_field_override.node.book.status.yml │ │ │ ├── core.base_field_override.node.book.sticky.yml │ │ │ ├── core.base_field_override.node.book.uid.yml │ │ │ ├── core.entity_form_display.node.book.default.yml │ │ │ ├── core.entity_view_display.node.book.default.yml │ │ │ ├── core.entity_view_display.node.book.teaser.yml │ │ │ ├── field.field.node.book.body.yml │ │ │ ├── field.field.node.book.field_author.yml │ │ │ ├── field.field.node.book.field_category.yml │ │ │ ├── field.field.node.book.field_cover.yml │ │ │ ├── field.storage.node.field_author.yml │ │ │ ├── field.storage.node.field_category.yml │ │ │ ├── field.storage.node.field_cover.yml │ │ │ ├── language.content_settings.node.book.yml │ │ │ ├── language.entity.lv.yml │ │ │ ├── node.type.book.yml │ │ │ ├── taxonomy.vocabulary.author.yml │ │ │ ├── taxonomy.vocabulary.category.yml │ │ │ └── user.role.editor.yml │ ├── migrate_source_example_setup.info.yml │ ├── migrate_source_example_setup.install │ └── migrate_source_example_setup.module └── migrate_source_example_xml │ ├── config │ └── install │ │ ├── migrate_plus.migration.migrate_source_example_xml_author.yml │ │ ├── migrate_plus.migration.migrate_source_example_xml_book.yml │ │ ├── migrate_plus.migration.migrate_source_example_xml_category.yml │ │ ├── migrate_plus.migration.migrate_source_example_xml_image.yml │ │ ├── migrate_plus.migration.migrate_source_example_xml_user.yml │ │ └── migrate_plus.migration_group.migrate_source_example_xml.yml │ ├── migrate_source_example_xml.info.yml │ ├── migrate_source_example_xml.module │ ├── source │ ├── attributes.xml │ ├── books.xml │ └── users.xml │ └── src │ └── Plugin │ └── migrate │ ├── process │ └── ExtractAttributeValues.php │ └── source │ └── UrlXml.php ├── source └── images │ ├── bourne-identity.png │ ├── bourne-supremacy.png │ ├── bourne-ultimatum.png │ ├── casino-royale.png │ ├── diamonds-are-forever.png │ ├── fellowship-of-the-ring.png │ ├── live-and-let-die.png │ ├── moonraker.png │ ├── return-of-the-king.png │ └── two-towers.png ├── src └── Plugin │ └── migrate │ ├── process │ ├── FilterMigratedSourceValues.php │ ├── FormatDate.php │ └── Walk.php │ └── source │ ├── Url.php │ └── UrlImage.php └── tests └── src └── Unit └── process ├── FormatDateTest.php └── WalkTest.php /README.md: -------------------------------------------------------------------------------- 1 | # Migrate source example 2 | 3 | `migrate_source_example` is a module that contains a set of sub-modules that provide content migrations from different 4 | sources. 5 | 6 | Currently the project features migrations from following sources: 7 | 8 | 1. External (non-Drupal) database tables. 9 | 2. CSV files; 10 | 3. XML files; 11 | 4. JSON resources. 12 | 13 | ## Installation 14 | 15 | 1. Install Drupal 8 compatible `drush`. 16 | 2. Install Drupal 8 using `Standard` profile. 17 | 3. Download `migrate_tools` contrib module into `modules/contrib/migrate_tools` (see [instructions](https://www.drupal.org/project/migrate_tools/git-instructions)). 18 | 4. Download `migrate_plus` contrib module into `modules/contrib/migrate_plus` (see [instructions](https://www.drupal.org/project/migrate_plus/git-instructions)). 19 | 5. Enable `migrate_source_example` module (`drush en migrate_source_example`). 20 | 21 | ### Installation of DB migration example module 22 | 1. Enable `migrate_source_example_db` module (`drush en migrate_source_example_db`). 23 | 24 | ### Installation of CSV migration example module 25 | 1. Download `migrate_source_csv` contrib module into `modules/contrib/migrate_source_csv` (see [instructions](https://www.drupal.org/project/migrate_source_csv/git-instructions)). 26 | 2. Enable `migrate_source_example_csv` module (`drush en migrate_source_example_csv`). 27 | 28 | ### Installation of XML migration example module 29 | 1. Enable `migrate_source_example_xml` module (`drush en migrate_source_example_xml`). 30 | 31 | ### Installation of JSON migration example module 32 | 1. Enable `migrate_source_example_json` module (`drush en migrate_source_example_json`). 33 | 34 | ## Usage 35 | 36 | 1. Run `drush ms` to see all migrations. 37 | 2. Run `drush mi --group=[GROUP]` to import content from specific example group. 38 | 39 | ## Special usage of JSON migration example 40 | 41 | JSON migration source plugin requires an absolute URL of a JSON resource to be set in migration .yml file due to 42 | an assumption that JSON resources are remote. It means that for JSON migration to work, a base url of the site 43 | needs to be provided to migration system. 44 | 45 | Run `drush mi --group=migrate_source_example_json --uri=[BASE_URL]`, where `[BASE_URL]` is an absolute path to your 46 | site. 47 | 48 | ## Data source 49 | 50 | Example content is synced with a [Google Spreadsheet](https://goo.gl/Iq2Tk6). 51 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "drupal/migrate_source_example", 3 | "type": "drupal-module", 4 | "description": "A set of migrate example modules that provide content migration from different sources.", 5 | "license": "GPL-2.0+", 6 | "minimum-stability": "dev", 7 | "repositories": [ 8 | { 9 | "type": "composer", 10 | "url": "https://packages.drupal.org/8" 11 | } 12 | ], 13 | "require": { 14 | "drupal/migrate_source_csv": "^2.0.0-rc2", 15 | "drupal/migrate_plus": "^3.0.0-beta1", 16 | "drupal/migrate_tools": "^3.0.0-beta1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /migrate_source_example.info.yml: -------------------------------------------------------------------------------- 1 | name: Migrate source example 2 | type: module 3 | description: A set of migrate example modules that provide content migration from different sources. 4 | core: 8.x 5 | package: Migration 6 | -------------------------------------------------------------------------------- /migrate_source_example.module: -------------------------------------------------------------------------------- 1 | &$definition) { 12 | if ($key == 'extract') { 13 | $definition['handle_multiples'] = TRUE; 14 | break; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /migrate_source_example.services.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wunderio/migrate_source_example/247275a81a638fa81ebb4a148736ded627a2e410/migrate_source_example.services.yml -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_author.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_csv 6 | - taxonomy 7 | id: migrate_source_example_csv_author 8 | migration_tags: null 9 | migration_group: migrate_source_example_csv 10 | label: Authors 11 | source: 12 | plugin: migrate_source_example_csv 13 | path: author.csv 14 | header_row_count: 1 15 | keys: 16 | - id 17 | constants: 18 | slash: / 19 | process: 20 | vid: 21 | plugin: default_value 22 | default_value: author 23 | name: name 24 | path: 25 | - 26 | plugin: skip_on_empty 27 | method: process 28 | source: alias 29 | - 30 | plugin: concat 31 | delimiter: null 32 | source: 33 | - constants/slash 34 | - alias 35 | destination: 36 | plugin: 'entity:taxonomy_term' 37 | migration_dependencies: { } 38 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_book.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | config: 5 | - migrate_plus.migration.migrate_source_example_csv_author 6 | - migrate_plus.migration.migrate_source_example_csv_category 7 | - migrate_plus.migration.migrate_source_example_csv_image 8 | - migrate_plus.migration.migrate_source_example_csv_user 9 | module: 10 | - migrate_source_example_csv 11 | - node 12 | id: migrate_source_example_csv_book 13 | migration_tags: null 14 | migration_group: migrate_source_example_csv 15 | label: Books 16 | source: 17 | plugin: migrate_source_example_csv 18 | path: book.csv 19 | header_row_count: 1 20 | keys: 21 | - id 22 | constants: 23 | slash: / 24 | process: 25 | type: 26 | plugin: default_value 27 | default_value: book 28 | uid: 29 | plugin: migration 30 | migration: migrate_source_example_csv_user 31 | source: uid 32 | title: title 33 | body/value: body 34 | body/format: body_format 35 | langcode: 36 | plugin: default_value 37 | default_value: en 38 | field_author: 39 | plugin: migration 40 | migration: migrate_source_example_csv_author 41 | source: author 42 | field_category: 43 | - 44 | plugin: explode 45 | delimiter: ',' 46 | source: category 47 | - 48 | plugin: migration 49 | migration: migrate_source_example_csv_category 50 | field_cover: 51 | plugin: migration 52 | migration: migrate_source_example_csv_image 53 | source: image 54 | created: 55 | plugin: format_date 56 | format: U 57 | source: created 58 | changed: '@created' 59 | path: 60 | - 61 | plugin: skip_on_empty 62 | method: process 63 | source: alias 64 | - 65 | plugin: concat 66 | delimiter: null 67 | source: 68 | - constants/slash 69 | - alias 70 | destination: 71 | plugin: 'entity:node' 72 | migration_dependencies: 73 | required: 74 | - migrate_source_example_csv_user 75 | - migrate_source_example_csv_author 76 | - migrate_source_example_csv_category 77 | - migrate_source_example_csv_image 78 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_book_translations.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | config: 5 | - migrate_plus.migration.migrate_source_example_csv_author 6 | - migrate_plus.migration.migrate_source_example_csv_category 7 | - migrate_plus.migration.migrate_source_example_csv_image 8 | - migrate_plus.migration.migrate_source_example_csv_user 9 | module: 10 | - migrate_source_example_csv 11 | - node 12 | id: migrate_source_example_csv_book_translations 13 | migration_tags: null 14 | migration_group: migrate_source_example_csv 15 | label: Books (translations) 16 | source: 17 | plugin: migrate_source_example_csv 18 | path: book_translations.csv 19 | header_row_count: 1 20 | keys: 21 | - id 22 | constants: 23 | slash: / 24 | process: 25 | type: 26 | plugin: default_value 27 | default_value: book 28 | uid: 29 | plugin: migration 30 | migration: migrate_source_example_csv_user 31 | source: uid 32 | title: title 33 | body/value: body 34 | body/format: body_format 35 | langcode: language 36 | field_author: 37 | plugin: migration 38 | migration: migrate_source_example_csv_author 39 | source: author 40 | field_category: 41 | - 42 | plugin: explode 43 | delimiter: ',' 44 | source: category 45 | - 46 | plugin: migration 47 | migration: migrate_source_example_csv_category 48 | field_cover: 49 | plugin: migration 50 | migration: migrate_source_example_csv_image 51 | source: image 52 | created: 53 | plugin: format_date 54 | format: U 55 | source: created 56 | changed: '@created' 57 | path: 58 | - 59 | plugin: skip_on_empty 60 | method: process 61 | source: alias 62 | - 63 | plugin: concat 64 | delimiter: null 65 | source: 66 | - constants/slash 67 | - alias 68 | destination: 69 | plugin: 'entity:node' 70 | translations: true 71 | migration_dependencies: 72 | required: 73 | - migrate_source_example_csv_user 74 | - migrate_source_example_csv_author 75 | - migrate_source_example_csv_category 76 | - migrate_source_example_csv_image 77 | - migrate_source_example_csv_book 78 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_category.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_csv 6 | - taxonomy 7 | id: migrate_source_example_csv_category 8 | migration_tags: null 9 | migration_group: migrate_source_example_csv 10 | label: Categories 11 | source: 12 | plugin: migrate_source_example_csv 13 | path: category.csv 14 | header_row_count: 1 15 | keys: 16 | - id 17 | constants: 18 | slash: / 19 | process: 20 | vid: 21 | plugin: default_value 22 | default_value: category 23 | name: name 24 | path: 25 | - 26 | plugin: skip_on_empty 27 | method: process 28 | source: alias 29 | - 30 | plugin: concat 31 | delimiter: null 32 | source: 33 | - constants/slash 34 | - alias 35 | destination: 36 | plugin: 'entity:taxonomy_term' 37 | migration_dependencies: { } 38 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_image.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - file 6 | - migrate_source_example_csv 7 | id: migrate_source_example_csv_image 8 | migration_tags: null 9 | migration_group: migrate_source_example_csv 10 | label: Image 11 | source: 12 | plugin: migrate_source_example_csv 13 | path: image.csv 14 | header_row_count: 1 15 | keys: 16 | - id 17 | constants: 18 | source_base_path: 'source/images' 19 | destination_base_path: 'public://' 20 | process: 21 | # Prepare full path of the source. 22 | source_full_path: 23 | - 24 | plugin: concat 25 | delimiter: / 26 | source: 27 | - constants/source_base_path 28 | - filename 29 | - 30 | plugin: urlencode 31 | # Prepare full path of the destination. 32 | destination_full_path: 33 | plugin: concat 34 | delimiter: / 35 | source: 36 | - constants/destination_base_path 37 | - filename 38 | uri: 39 | plugin: file_copy 40 | source: 41 | - '@source_full_path' 42 | - '@destination_full_path' 43 | destination: 44 | plugin: 'entity:file' 45 | migration_dependencies: { } 46 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration.migrate_source_example_csv_user.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_csv 6 | - user 7 | id: migrate_source_example_csv_user 8 | migration_tags: null 9 | migration_group: migrate_source_example_csv 10 | label: Users 11 | source: 12 | plugin: migrate_source_example_csv 13 | path: user.csv 14 | header_row_count: 1 15 | keys: 16 | - id 17 | process: 18 | name: 19 | plugin: dedupe_entity 20 | entity_type: user 21 | field: name 22 | source: name 23 | mail: email 24 | init: email 25 | status: 26 | plugin: default_value 27 | default_value: 1 28 | roles: 29 | - 30 | plugin: explode 31 | delimiter: ',' 32 | source: roles 33 | destination: 34 | plugin: 'entity:user' 35 | migration_dependencies: { } 36 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/config/install/migrate_plus.migration_group.migrate_source_example_csv.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_csv 6 | enforced: 7 | module: 8 | - migrate_source_example_csv 9 | id: migrate_source_example_csv 10 | label: 'Example migration from CSV files.' 11 | description: 'A few example migrations from CSV files.' 12 | source_type: 'CSV files' 13 | module: null 14 | shared_configuration: 15 | source: 16 | key: default 17 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/migrate_source_example_csv.info.yml: -------------------------------------------------------------------------------- 1 | name: CSV migration example 2 | type: module 3 | description: Example module that provides content migration from CSV files. 4 | core: 8.x 5 | package: Migration 6 | dependencies: 7 | - migrate_source_example 8 | - migrate_source_example_setup 9 | - migrate_plus 10 | - migrate_tools 11 | - migrate_source_csv 12 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/migrate_source_example_csv.module: -------------------------------------------------------------------------------- 1 | The British Secret Service agent James Bond is sent by his superior, M, to New York City to investigate ""Mr Big"", real name Buonaparte Ignace Gallia.
",basic_html,2,1,1,3,2015-05-24T16:30:00,live-and-let-die 9 | 3,Moonraker,"The British Secret Service agent James Bond is asked by his superior, M, to join him at M's club, Blades.
",basic_html,3,1,1,3,2015-06-01T17:25:00,moonraker 10 | 4,Diamonds Are Forever,"The British Secret Service agent James Bond is sent on an assignment by his superior, M.
",basic_html,4,1,1,3,2015-06-14T09:45:00,diamonds-are-forever 11 | 5,The Bourne Identity,"The preface of the novel consists of two real-life newspaper articles from 1975 about terrorist Ilich Ramírez Sánchez, known as ""Carlos the Jackal.""
",basic_html,5,2,1,1,2015-06-15T12:00:00,the-bourne-identity 12 | 6,The Bourne Supremacy,The story of The Bourne Supremacy is set during the British negotiated handover of Hong Kong to the People's Republic of China on the expiration of its ninety-nine-year lease on the New Territories.
,basic_html,6,2,1,1,2015-06-25T14:45:00,the-bourne-supremacy 13 | 7,The Bourne Ultimatum,"The novel follows David Webb, alias Jason Bourne, as he works to find his old enemy, Carlos the Jackal, who is trying to kill him.
",basic_html,7,2,1,1,2015-07-07T16:15:00,the-bourne-ultimatum 14 | 8,The Fellowship of the Ring,"Thousands of years before the events of the novel, the Dark Lord Sauron had forged the One Ring to rule the other Rings of Power and corrupt those who wear them: the leaders of Men, Elves and Dwarves.
",basic_html,8,3,"3,2",2,2015-07-14T18:30:00, 15 | 9,The Two Towers,"Orcs sent by Saruman and Sauron kill Boromir and kidnap Merry and Pippin. After agonizing over which pair of hobbits to follow, Aragorn, Gimli and Legolas pursue the orcs bearing Merry and Pippin to Saruman.
",basic_html,9,3,"3,2",2,2015-07-18T20:45:00, 16 | 10,The Return of the King,Sauron unleashes a heavy assault upon Gondor. Gandalf arrives at Minas Tirith to alert Denethor of the impending attack.
,basic_html,10,3,"3,2",2,2015-07-28T09:15:00, 17 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/source/book_translations.csv: -------------------------------------------------------------------------------- 1 | id,language,title,body,body_format,image,author,category,uid,created,alias 2 | 9,lv,Divi torņi,"Tiklīdz gredzens atgriezīsies pie tā kaldinātāja, Tumsas pavēlnieka Saurona, tas iegūs spēku paverdzināt visu pasauli.
",basic_html,9,3,"3,2",2,2015-07-18T20:45:00,divi-torni 3 | 4,lv,Dimanti ir mūžīgi,Britu spiegu aģents Džeims Bonds ir nosūtīts uzdevumā.
,basic_html,4,1,1,3,2015-06-14T09:45:00,dimanti-ir-muzigi 4 | 5,lv,Borna identitāte,"Itāliešu zvejnieki no Vidusjūras izvelk tik tikko dzīvu cilvēku. Viņš cieš no atmiņas zuduma, un vienīgā norāde par viņa personību un bankas konta numurs, kas iespiests uz kapsulas, kura implantēta viņa ķermenī. Bankas seifā atradis pases ar dažādām identitātēm, naudas žūksni un revolveri, viņš pieņem Džeisona Borna vārdu kā ticamāko no variantiem un dodas savas patiesās personības meklējumos.
",basic_html,5,2,1,1,2015-06-15T12:00:00,borna-identitate 5 | 6,lv,Borna pārspēks,"Ķīnas vicepremjeru likvidē algots slepkava, kura vārds tūdaļ nokļūst atklātībā Džeisons Borns. CIP ir neizpratnē. Patiesībā tāda Borna nemaz nav, jo tas ir šī kantora aģenta Deivida Veba darba segvārds. Tātad sanāk, ka kāds ir piesavinājies viņa segvārdu Džeisons Borns, lai izdarītu noziegumu, izprovocējot ar to diplomātisko krīzi ASV un Ķīnas starpā. Deividam neatliek nekas cits, kā pašam atklāt šo mīklaino lietu.
",basic_html,6,2,1,1,2015-06-25T14:45:00,borna-parspeks 6 | 7,lv,Borna ultimāts,"Viņš vēlējās tikai vienu - nozust. Tā vietā tagad Džeisonu Bornu vajā cilvēki, kas viņu padarījuši par to, kas viņš ir. Lai atrastu savu vietu nākotnē, viņam jānoskaidro sava pagātne.
",basic_html,7,2,1,1,2015-07-07T16:15:00,borna-ultimats 7 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/source/category.csv: -------------------------------------------------------------------------------- 1 | id,name,alias 2 | 1,Spy Stories,category/spy-stories 3 | 2,Fantasy,category/fantasy 4 | 3,Fiction,category/fiction 5 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/source/image.csv: -------------------------------------------------------------------------------- 1 | id,filename 2 | 1,casino-royale.png 3 | 2,live-and-let-die.png 4 | 3,moonraker.png 5 | 4,diamonds-are-forever.png 6 | 5,bourne-identity.png 7 | 6,bourne-supremacy.png 8 | 7,bourne-ultimatum.png 9 | 8,fellowship-of-the-ring.png 10 | 9,two-towers.png 11 | 10,return-of-the-king.png 12 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/source/user.csv: -------------------------------------------------------------------------------- 1 | id,name,roles,email 2 | 1,Nifs,"administrator,editor",nifs@nifs.com 3 | 2,Nufs,"editor",nufs@nufs.com 4 | 3,Nafs,"editor",nafs@nafs.com 5 | -------------------------------------------------------------------------------- /modules/migrate_source_example_csv/src/Plugin/migrate/source/CSV.php: -------------------------------------------------------------------------------- 1 | setFlags(CSVFileObject::READ_CSV | CSVFileObject::READ_AHEAD | CSVFileObject::SKIP_EMPTY); 55 | return $file; 56 | } 57 | 58 | /** 59 | * Attaches "nid" property to row's destination to match the ID of content 60 | * source. 61 | * 62 | * @param \Drupal\migrate\Row $row 63 | * 64 | * @return bool 65 | * @throws \Exception 66 | */ 67 | function prepareRow(Row $row) { 68 | // Storage for destination ID indexes. 69 | static $destinationNidIndex = []; 70 | // Storage for book migration. Translations require destination ID of the 71 | // content source. 72 | static $bookMigration; 73 | // Storage for migration destination configuration. 74 | static $destinationConfiguration; 75 | 76 | $migrationId = $this->migration->id(); 77 | 78 | if (!isset($destinationConfiguration[$migrationId])) { 79 | $destinationConfiguration[$migrationId] = $this->migration->getDestinationConfiguration(); 80 | } 81 | 82 | if (!empty($destinationConfiguration[$migrationId]['translations'])) { 83 | if (!isset($bookMigration)) { 84 | $bookMigration = \Drupal::service('plugin.manager.migration')->createInstance('migrate_source_example_csv_book'); 85 | } 86 | 87 | // Get the index of "nid" field for destination on the migration map. 88 | if (!isset($destinationNidIndex[$migrationId])) { 89 | $ids = $this->migration->getDestinationPlugin()->getIds(); 90 | $destinationNidIndex[$migrationId] = array_search('nid', array_keys($ids)); 91 | } 92 | 93 | // Get the destination ID of the book. 94 | if ($destination = $bookMigration->getIdMap()->lookupDestinationIds(['id' => $row->getSourceProperty('id')])) { 95 | $destination = reset($destination); 96 | $row->setDestinationProperty('nid', $destination[$destinationNidIndex[$migrationId]]); 97 | } 98 | 99 | } 100 | return parent::prepareRow($row); 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration.migrate_source_example_db_author.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_db 6 | - taxonomy 7 | id: migrate_source_example_db_author 8 | migration_tags: null 9 | migration_group: migrate_source_example_db 10 | label: Authors 11 | source: 12 | plugin: migrate_source_example_db_taxonomy_attribute 13 | attribute_type: attribute_authors 14 | constants: 15 | path_prefix: author 16 | slash: / 17 | process: 18 | vid: 19 | plugin: default_value 20 | default_value: author 21 | name: name 22 | path: 23 | - 24 | plugin: skip_on_empty 25 | method: process 26 | source: machine_name 27 | - 28 | plugin: concat 29 | delimiter: null 30 | source: 31 | - constants/slash 32 | - constants/path_prefix 33 | - constants/slash 34 | - machine_name 35 | destination: 36 | plugin: 'entity:taxonomy_term' 37 | migration_dependencies: { } 38 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration.migrate_source_example_db_book.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | config: 5 | - migrate_plus.migration.migrate_source_example_db_author 6 | - migrate_plus.migration.migrate_source_example_db_category 7 | - migrate_plus.migration.migrate_source_example_db_image 8 | - migrate_plus.migration.migrate_source_example_db_user 9 | module: 10 | - migrate_source_example_db 11 | - node 12 | id: migrate_source_example_db_book 13 | migration_tags: null 14 | migration_group: migrate_source_example_db 15 | label: Books 16 | source: 17 | plugin: migrate_source_example_db_book 18 | constants: 19 | slash: / 20 | process: 21 | type: 22 | plugin: default_value 23 | default_value: book 24 | langcode: langcode 25 | nid: 26 | - 27 | plugin: skip_on_empty 28 | method: process 29 | source: nid 30 | uid: 31 | plugin: migration_lookup 32 | migration: migrate_source_example_db_user 33 | source: user 34 | title: title 35 | body/value: body 36 | body/format: 37 | plugin: static_map 38 | source: body_format 39 | map: 40 | 1: plain_text 41 | 2: basic_html 42 | field_author: 43 | plugin: migration_lookup 44 | migration: migrate_source_example_db_author 45 | source: author 46 | field_category: 47 | - 48 | plugin: explode 49 | delimiter: ', ' 50 | source: category 51 | - 52 | plugin: migration_lookup 53 | migration: migrate_source_example_db_category 54 | field_cover: 55 | plugin: migration_lookup 56 | migration: migrate_source_example_db_image 57 | source: image 58 | created: 59 | plugin: format_date 60 | format: U 61 | source: created 62 | changed: '@created' 63 | path: 64 | - 65 | plugin: skip_on_empty 66 | method: process 67 | source: alias 68 | - 69 | plugin: concat 70 | delimiter: null 71 | source: 72 | - constants/slash 73 | - alias 74 | destination: 75 | plugin: 'entity:node' 76 | translations: true 77 | migration_dependencies: 78 | required: 79 | - migrate_source_example_db_user 80 | - migrate_source_example_db_author 81 | - migrate_source_example_db_category 82 | - migrate_source_example_db_image 83 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration.migrate_source_example_db_category.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_db 6 | - taxonomy 7 | id: migrate_source_example_db_category 8 | migration_tags: null 9 | migration_group: migrate_source_example_db 10 | label: Categories 11 | source: 12 | plugin: migrate_source_example_db_taxonomy_attribute 13 | attribute_type: attribute_category 14 | constants: 15 | path_prefix: category 16 | slash: / 17 | process: 18 | vid: 19 | plugin: default_value 20 | default_value: category 21 | name: name 22 | path: 23 | - 24 | plugin: skip_on_empty 25 | method: process 26 | source: machine_name 27 | - 28 | plugin: concat 29 | delimiter: null 30 | source: 31 | - constants/slash 32 | - constants/path_prefix 33 | - constants/slash 34 | - machine_name 35 | destination: 36 | plugin: 'entity:taxonomy_term' 37 | migration_dependencies: { } 38 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration.migrate_source_example_db_image.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - file 6 | - migrate_source_example_db 7 | id: migrate_source_example_db_image 8 | migration_tags: null 9 | migration_group: migrate_source_example_db 10 | label: Image 11 | source: 12 | plugin: migrate_source_example_db_image 13 | constants: 14 | source_base_path: 'source/images' 15 | destination_base_path: 'public://' 16 | process: 17 | # Prepare full path of the source. 18 | source_full_path: 19 | - 20 | plugin: concat 21 | delimiter: / 22 | source: 23 | - constants/source_base_path 24 | - filename 25 | - 26 | plugin: urlencode 27 | # Prepare full path of the destination. 28 | destination_full_path: 29 | plugin: concat 30 | delimiter: / 31 | source: 32 | - constants/destination_base_path 33 | - filename 34 | uri: 35 | plugin: file_copy 36 | source: 37 | - '@source_full_path' 38 | - '@destination_full_path' 39 | destination: 40 | plugin: 'entity:file' 41 | migration_dependencies: { } 42 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration.migrate_source_example_db_user.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_db 6 | - user 7 | id: migrate_source_example_db_user 8 | migration_tags: null 9 | migration_group: migrate_source_example_db 10 | label: Users 11 | source: 12 | plugin: migrate_source_example_db_user 13 | process: 14 | name: 15 | plugin: dedupe_entity 16 | entity_type: user 17 | field: name 18 | source: name 19 | roles: 20 | - 21 | plugin: explode 22 | delimiter: ', ' 23 | source: roles 24 | - 25 | plugin: static_map 26 | map: 27 | 1: administrator 28 | 2: editor 29 | mail: email 30 | init: email 31 | status: 32 | plugin: default_value 33 | default_value: 1 34 | destination: 35 | plugin: 'entity:user' 36 | migration_dependencies: { } 37 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/config/install/migrate_plus.migration_group.migrate_source_example_db.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_db 6 | enforced: 7 | module: 8 | - migrate_source_example_db 9 | id: migrate_source_example_db 10 | label: 'Example migration from a dababase.' 11 | description: 'A few example migrations from custom (e.g., external) database tables.' 12 | source_type: 'Custom tables' 13 | module: null 14 | shared_configuration: 15 | # Specifying 'source' here means that this configuration will be merged into 16 | # the 'source' configuration of each migration. 17 | source: 18 | # A better practice for real-world migrations would be to add a database 19 | # connection to your external database in settings.php and reference its 20 | # key here. 21 | key: default 22 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/migrate_source_example_db.info.yml: -------------------------------------------------------------------------------- 1 | name: DB migration example 2 | type: module 3 | description: Example module that provides content migration from DB. 4 | core: 8.x 5 | package: Migration 6 | dependencies: 7 | - migrate_source_example 8 | - migrate_source_example_setup 9 | - migrate_plus 10 | - migrate_tools 11 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/migrate_source_example_db.install: -------------------------------------------------------------------------------- 1 | getEditable($config) 52 | ->delete(); 53 | } 54 | } 55 | /** 56 | * Defines schema for migrate_source_example_db_users table. 57 | * 58 | * Defines migrate_source_example_db_users table schema with uid (unique), 59 | * name, roles and email fields. 60 | * 61 | * @return array 62 | */ 63 | function migrate_source_example_db_schema_users() { 64 | return array( 65 | 'fields' => array( 66 | 'uid' => array( 67 | 'type' => 'int', 68 | 'not null' => TRUE, 69 | 'description' => 'User ID', 70 | ), 71 | 'name' => array( 72 | 'type' => 'varchar', 73 | 'length' => 15, 74 | 'not null' => TRUE, 75 | 'description' => 'User name', 76 | ), 77 | 'roles' => array( 78 | 'type' => 'varchar', 79 | 'length' => 30, 80 | 'not null' => TRUE, 81 | 'description' => 'User roles', 82 | ), 83 | 'email' => array( 84 | 'type' => 'varchar', 85 | 'length' => 30, 86 | 'not null' => TRUE, 87 | 'description' => 'User roles. "1" is administrator, "2" is editor', 88 | ), 89 | ), 90 | 'unique keys' => array( 91 | 'uid' => array('uid'), 92 | ), 93 | ); 94 | } 95 | 96 | /** 97 | * Defines schema for migrate_source_example_db_attributes table. 98 | * 99 | * Defines migrate_source_example_db_attributes table schema with aid (unique), 100 | * type, name and machine_name fields. 101 | * 102 | * @return array 103 | */ 104 | function migrate_source_example_db_schema_attributes() { 105 | return array( 106 | 'fields' => array( 107 | 'aid' => array( 108 | 'type' => 'int', 109 | 'not null' => TRUE, 110 | 'description' => 'Attribute ID', 111 | ), 112 | 'type' => array( 113 | 'type' => 'varchar', 114 | 'length' => 30, 115 | 'not null' => TRUE, 116 | 'description' => 'Attribute type', 117 | ), 118 | 'name' => array( 119 | 'type' => 'varchar', 120 | 'length' => 30, 121 | 'not null' => TRUE, 122 | 'description' => 'Attribute name', 123 | ), 124 | 'machine_name' => array( 125 | 'type' => 'varchar', 126 | 'length' => 30, 127 | 'not null' => TRUE, 128 | 'description' => 'Attribute alias', 129 | ), 130 | ), 131 | 'unique keys' => array( 132 | 'aid' => array('aid'), 133 | ), 134 | ); 135 | } 136 | 137 | /** 138 | * Defines schema for migrate_source_example_db_files table. 139 | * 140 | * Defines migrate_source_example_db_files table schema with 141 | * fid (unique) and filename fields. 142 | * 143 | * @return array 144 | */ 145 | function migrate_source_example_db_schema_files() { 146 | return array( 147 | 'fields' => array( 148 | 'fid' => array( 149 | 'type' => 'int', 150 | 'not null' => TRUE, 151 | 'description' => 'File ID', 152 | ), 153 | 'filename' => array( 154 | 'type' => 'varchar', 155 | 'length' => 30, 156 | 'not null' => TRUE, 157 | 'description' => 'File name', 158 | ), 159 | ), 160 | 'unique keys' => array( 161 | 'fid' => array('fid'), 162 | ), 163 | ); 164 | } 165 | 166 | /** 167 | * Defines schema for migrate_source_example_db_books table. 168 | * 169 | * Defines migrate_source_example_db_books table schema with id (unique), bid, langcode, 170 | * title, body, body_format, image, attributes, user, created and alias fields. 171 | * 172 | * @return array 173 | */ 174 | function migrate_source_example_db_schema_books() { 175 | return array( 176 | 'fields' => array( 177 | 'id' => array( 178 | 'type' => 'int', 179 | 'not null' => TRUE, 180 | 'description' => 'Entry ID', 181 | ), 182 | 'bid' => array( 183 | 'type' => 'int', 184 | 'not null' => TRUE, 185 | 'description' => 'Book ID', 186 | ), 187 | 'langcode' => array( 188 | 'type' => 'varchar', 189 | 'length' => 5, 190 | 'not null' => TRUE, 191 | 'description' => 'Langcode', 192 | ), 193 | 'title' => array( 194 | 'type' => 'varchar', 195 | 'length' => 50, 196 | 'not null' => TRUE, 197 | 'description' => 'Title of book', 198 | ), 199 | 'body' => array( 200 | 'type' => 'varchar', 201 | 'length' => 1000, 202 | 'not null' => TRUE, 203 | 'description' => 'File name', 204 | ), 205 | 'body_format' => array( 206 | 'type' => 'varchar', 207 | 'length' => 20, 208 | 'not null' => TRUE, 209 | 'description' => 'Body format. "1" is plain text, "2" is basic html', 210 | ), 211 | 'image' => array( 212 | 'type' => 'int', 213 | 'not null' => TRUE, 214 | 'description' => 'File id', 215 | ), 216 | 'author' => array( 217 | 'type' => 'varchar', 218 | 'length' => 30, 219 | 'not null' => TRUE, 220 | 'description' => 'Author id', 221 | ), 222 | 'category' => array( 223 | 'type' => 'varchar', 224 | 'length' => 30, 225 | 'not null' => TRUE, 226 | 'description' => 'Category id', 227 | ), 228 | 'user' => array( 229 | 'type' => 'int', 230 | 'not null' => TRUE, 231 | 'description' => 'User id', 232 | ), 233 | 'created' => array( 234 | 'type' => 'varchar', 235 | 'length' => 25, 236 | 'not null' => TRUE, 237 | 'description' => 'Create time', 238 | ), 239 | 'alias' => array( 240 | 'type' => 'varchar', 241 | 'length' => 30, 242 | 'description' => 'Book alias', 243 | ), 244 | ), 245 | 'unique keys' => array( 246 | 'fid' => array('id'), 247 | ), 248 | ); 249 | } 250 | 251 | /** 252 | * Create content for migrate_source_example_db_users table. 253 | */ 254 | function migrate_source_example_db_data_users() { 255 | $fields = array('uid', 'name', 'roles', 'email'); 256 | $query = Database::getConnection()->insert('migrate_source_example_db_users') 257 | ->fields($fields); 258 | 259 | $data = array( 260 | array(1, 'Nifs', '1, 2', 'nifs@nifs.com'), 261 | array(2, 'Nufs', '2', 'nufs@nufs.com'), 262 | array(3, 'Nafs', '2', 'nafs@nafs.com'), 263 | ); 264 | 265 | foreach ($data as $row) { 266 | $query->values(array_combine($fields, $row)); 267 | } 268 | $query->execute(); 269 | } 270 | 271 | /** 272 | * Create content for migrate_source_example_db_attributes table. 273 | */ 274 | function migrate_source_example_db_data_attributes() { 275 | $fields = array('aid', 'type', 'name', 'machine_name'); 276 | $query = Database::getConnection()->insert('migrate_source_example_db_attributes') 277 | ->fields($fields); 278 | 279 | $data = array( 280 | array(1, 'attribute_authors', 'Ian Fleming', 'ian-fleming'), 281 | array(2, 'attribute_authors', 'Robert Ludlum', 'robert-ludlum'), 282 | array(3, 'attribute_authors', 'John Ronald Reuel Tolkien', 'jrr-tolkien'), 283 | array(4, 'attribute_category', 'Spy Stories', 'spy-stories'), 284 | array(5, 'attribute_category', 'Fantasy', 'fantasy'), 285 | array(6, 'attribute_category', 'Fiction', 'fiction'), 286 | ); 287 | 288 | foreach ($data as $row) { 289 | $query->values(array_combine($fields, $row)); 290 | } 291 | $query->execute(); 292 | } 293 | 294 | /** 295 | * Create content for migrate_source_example_db_files table. 296 | */ 297 | function migrate_source_example_db_data_files() { 298 | $fields = array('fid', 'filename'); 299 | $query = Database::getConnection()->insert('migrate_source_example_db_files') 300 | ->fields($fields); 301 | 302 | $data = array( 303 | array(1, 'casino-royale.png'), 304 | array(2, 'live-and-let-die.png'), 305 | array(3, 'moonraker.png'), 306 | array(4, 'diamonds-are-forever.png'), 307 | array(5, 'bourne-identity.png'), 308 | array(6, 'bourne-supremacy.png'), 309 | array(7, 'bourne-ultimatum.png'), 310 | array(8, 'fellowship-of-the-ring.png'), 311 | array(9, 'two-towers.png'), 312 | array(10, 'return-of-the-king.png'), 313 | ); 314 | 315 | foreach ($data as $row) { 316 | $query->values(array_combine($fields, $row)); 317 | } 318 | $query->execute(); 319 | } 320 | 321 | /** 322 | * Create content for migrate_source_example_db_books table. 323 | */ 324 | function migrate_source_example_db_data_books() { 325 | $fields = array('id', 'bid', 'langcode', 'title', 'body', 'body_format', 'image', 'author', 'category', 'user', 'created', 'alias'); 326 | $query = Database::getConnection()->insert('migrate_source_example_db_books') 327 | ->fields($fields); 328 | 329 | $data = array( 330 | array(1, 1, 'en', 'Casino Royale', 'M, 331 | the Head of the British Secret Service, 332 | assigns James Bond, 007, 333 | to play against and bankrupt Le Chiffre, 334 | the paymaster for a SMERSH-controlled trade union, 335 | in a high-stakes baccarat game at the Royale-les-Eaux casino in northern France.', '1', 1, 1, 4, 3, '2015-04-02 21:00:00', 'casino-royale'), 336 | array(2, 2, 'en', 'Live and Let Die', 'The British Secret Service agent James Bond is sent by his superior, M, to New York City to investigate "Mr Big", real name Buonaparte Ignace Gallia.
', '2', 2, 1, 4, 3, '2015-05-24 16:30:00', 'live-and-let-die'), 337 | array(3, 3, 'en', 'Moonraker', "The British Secret Service agent James Bond is asked by his superior, M, to join him at M's club, Blades.
", '2', 3, 1, 4, 3, '2015-06-01 17:25:00', 'moonraker'), 338 | array(4, 4, 'en', 'Diamonds Are Forever', "The British Secret Service agent James Bond is sent on an assignment by his superior, M.
", '2', 4, 1, 4, 3, '2015-06-14 09:45:00', 'diamonds-are-forever'), 339 | array(5, 5, 'en', 'The Bourne Identity', 'The preface of the novel consists of two real-life newspaper articles from 1975 about terrorist Ilich Ramírez Sánchez, known as "Carlos the Jackal."
', '2', 5, 2, 4, 1, '2015-06-15 12:00:00', 'the-bourne-identity'), 340 | array(6, 6, 'en', 'The Bourne Supremacy', "The story of The Bourne Supremacy is set during the British negotiated handover of Hong Kong to the People's Republic of China on the expiration of its ninety-nine-year lease on the New Territories.
", '2', 6, 2, 4, 1, '2015-06-25 14:45:00', 'the-bourne-supremacy'), 341 | array(7, 7, 'en', 'The Bourne Ultimatum', "The novel follows David Webb, alias Jason Bourne, as he works to find his old enemy, Carlos the Jackal, who is trying to kill him.
", '2', 7, 2, 4, 1, '2015-07-07 16:15:00', 'the-bourne-ultimatum'), 342 | array(8, 8, 'en', 'The Fellowship of the Ring', "Thousands of years before the events of the novel, the Dark Lord Sauron had forged the One Ring to rule the other Rings of Power and corrupt those who wear them: the leaders of Men, Elves and Dwarves.
", '2', 8, 3, '5, 6', 2, '2015-07-14 18:30:00', ''), 343 | array(9, 9, 'en', 'The Two Towers', "Orcs sent by Saruman and Sauron kill Boromir and kidnap Merry and Pippin. After agonizing over which pair of hobbits to follow, Aragorn, Gimli and Legolas pursue the orcs bearing Merry and Pippin to Saruman.
", '2', 9, 3, '5, 6', 2, '2015-07-18 20:45:00', ''), 344 | array(10, 10, 'en', 'The Return of the King', "Sauron unleashes a heavy assault upon Gondor. Gandalf arrives at Minas Tirith to alert Denethor of the impending attack.
", '2', 10, 3, '5, 6', 2, '2015-07-28 09:15:00', ''), 345 | array(11, 9, 'lv', 'Divi torņi', "Tiklīdz gredzens atgriezīsies pie tā kaldinātāja, Tumsas pavēlnieka Saurona, tas iegūs spēku paverdzināt visu pasauli.
", '2', 9, 3, '5, 6', 2, '2015-07-18 20:45:00', 'divi-torni'), 346 | array(12, 4, 'lv', 'Dimanti ir mūžīgi', "Britu spiegu aģents Džeims Bonds ir nosūtīts uzdevumā.
", '2', 4, 1, 4, 3, '2015-06-14 09:45:00', 'dimanti-ir-muzigi'), 347 | array(13, 5, 'lv', 'Borna identitāte', 'Itāliešu zvejnieki no Vidusjūras izvelk tik tikko dzīvu cilvēku. Viņš cieš no atmiņas zuduma, un vienīgā norāde par viņa personību un bankas konta numurs, kas iespiests uz kapsulas, kura implantēta viņa ķermenī. Bankas seifā atradis pases ar dažādām identitātēm, naudas žūksni un revolveri, viņš pieņem Džeisona Borna vārdu kā ticamāko no variantiem un dodas savas patiesās personības meklējumos.
', '2', 5, 2, 4, 1, '2015-06-15 12:00:00', 'borna-identitate'), 348 | array(14, 6, 'lv', 'Borna pārspēks', "Ķīnas vicepremjeru likvidē algots slepkava, kura vārds tūdaļ nokļūst atklātībā Džeisons Borns. CIP ir neizpratnē. Patiesībā tāda Borna nemaz nav, jo tas ir šī kantora aģenta Deivida Veba darba segvārds. Tātad sanāk, ka kāds ir piesavinājies viņa segvārdu Džeisons Borns, lai izdarītu noziegumu, izprovocējot ar to diplomātisko krīzi ASV un Ķīnas starpā. Deividam neatliek nekas cits, kā pašam atklāt šo mīklaino lietu.
", '2', 6, 2, 4, 1, '2015-06-25 14:45:00', 'borna-parspeks'), 349 | array(15, 7, 'lv', 'Borna ultimāts', "Viņš vēlējās tikai vienu - nozust. Tā vietā tagad Džeisonu Bornu vajā cilvēki, kas viņu padarījuši par to, kas viņš ir. Lai atrastu savu vietu nākotnē, viņam jānoskaidro sava pagātne.
", '2', 7, 2, 4, 1, '2015-07-07 16:15:00', 'borna-ultimats'), 350 | ); 351 | 352 | foreach ($data as $row) { 353 | $query->values(array_combine($fields, $row)); 354 | } 355 | $query->execute(); 356 | } 357 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/migrate_source_example_db.module: -------------------------------------------------------------------------------- 1 | ' . t('About') . ''; 19 | $output .= '' . t('Example module that provides content migration from DB.') . '
'; 20 | return $output; 21 | 22 | default: 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/src/Plugin/migrate/source/Book.php: -------------------------------------------------------------------------------- 1 | select('migrate_source_example_db_books', 'b') 28 | ->fields('b', array('id', 'bid', 'langcode', 'title', 'body', 'body_format', 'image', 'author', 'category', 'user', 'created', 'alias')); 29 | } 30 | 31 | /** 32 | * {@inheritdoc} 33 | */ 34 | public function fields() { 35 | $fields['bid'] = $this->t('Bid'); 36 | $fields['langcode'] = $this->t('Langcode'); 37 | $fields['title'] = $this->t('Title'); 38 | $fields['body'] = $this->t('Body'); 39 | $fields['body_format'] = $this->t('Body format'); 40 | $fields['image'] = $this->t('Image'); 41 | $fields['author'] = $this->t('Author'); 42 | $fields['category'] = $this->t('Category'); 43 | $fields['user'] = $this->t('User'); 44 | $fields['created'] = $this->t('Created'); 45 | $fields['alias'] = $this->t('Alias'); 46 | return $fields; 47 | } 48 | 49 | 50 | /** 51 | * {@inheritdoc} 52 | */ 53 | public function getIds() { 54 | return array( 55 | 'id' => array( 56 | 'type' => 'integer', 57 | ), 58 | // Store book ID in map to have a reference for translations. 59 | // See self::prepareRow() 60 | 'bid' => array( 61 | 'type' => 'integer', 62 | ), 63 | ); 64 | } 65 | 66 | /** 67 | * Attaches "nid" property to a row if row "bid" points to a 68 | * 69 | * @param \Drupal\migrate\Row $row 70 | * 71 | * @return bool 72 | * @throws \Exception 73 | */ 74 | function prepareRow(Row $row) { 75 | static $destinationNidIndex; 76 | 77 | // Get the index of "nid" field for destination on the migration map. 78 | if (!isset($destinationNidIndex)) { 79 | $ids = $this->migration->getDestinationPlugin()->getIds(); 80 | $destinationNidIndex = array_search('nid', array_keys($ids)); 81 | } 82 | 83 | // Check the map if other translation has been imported. Query is done by 84 | // "bid" key which is mapped for this source. 85 | if ($destination = $this->idMap->lookupDestinationIds(['bid' => $row->getSourceProperty('bid')])) { 86 | $destination = reset($destination); 87 | $row->setSourceProperty('nid', $destination[$destinationNidIndex]); 88 | } 89 | 90 | return parent::prepareRow($row); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/src/Plugin/migrate/source/Image.php: -------------------------------------------------------------------------------- 1 | select('migrate_source_example_db_files', 'u') 42 | ->fields('u', array('fid','filename')); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function fields() { 49 | $fields['fid'] = $this->t('File ID'); 50 | $fields['filename'] = $this->t('File name'); 51 | return $fields; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | public function getIds() { 58 | return array( 59 | 'fid' => array( 60 | 'type' => 'integer', 61 | 'alias' => 'u', 62 | ), 63 | ); 64 | } 65 | 66 | /** 67 | * {@inheritdoc} 68 | */ 69 | public function prepareRow(Row $row) { 70 | parent::prepareRow($row); 71 | // Get filename property value. 72 | $filename = $row->getSourceProperty('filename'); 73 | // Prepare base path. 74 | $base_path = trim($this->configuration['source_base_path'], '/'); 75 | // Set "full_path" property to point to the full path of the image. 76 | $base_module_path = drupal_get_path('module', 'migrate_source_example'); 77 | $row->setSourceProperty('full_path', $base_module_path . '/' . $base_path . '/' . $filename); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/src/Plugin/migrate/source/TaxonomyAttribute.php: -------------------------------------------------------------------------------- 1 | configuration['attribute_type'])) { 33 | throw new MigrateException('You must declare the "attribute_type" to define the attribute being migrated.'); 34 | } 35 | 36 | return $this->select($this->table, '_table_alias') 37 | ->fields('_table_alias') 38 | ->condition('type', $this->configuration['attribute_type']); 39 | } 40 | 41 | /** 42 | * {@inheritdoc} 43 | */ 44 | public function fields() { 45 | return [ 46 | 'aid' => $this->t('Attribute ID'), 47 | 'type' => $this->t('Attribute type'), 48 | 'name' => $this->t('Attribute name'), 49 | 'alias' => $this->t('Attribute alias'), 50 | ]; 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | public function getIds() { 57 | return [ 58 | 'aid' => [ 59 | 'type' => 'integer', 60 | ], 61 | ]; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /modules/migrate_source_example_db/src/Plugin/migrate/source/User.php: -------------------------------------------------------------------------------- 1 | select('migrate_source_example_db_users', 'u') 27 | ->fields('u', array('uid','name','roles','email')); 28 | } 29 | 30 | /** 31 | * {@inheritdoc} 32 | */ 33 | public function fields() { 34 | $fields['uid'] = $this->t('Uid'); 35 | $fields['name'] = $this->t('Name'); 36 | $fields['roles'] = $this->t('Roles'); 37 | $fields['email'] = $this->t('Email'); 38 | return $fields; 39 | } 40 | 41 | 42 | /** 43 | * {@inheritdoc} 44 | */ 45 | public function getIds() { 46 | return array( 47 | 'uid' => array( 48 | 'type' => 'integer', 49 | 'alias' => 'u', 50 | ), 51 | ); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration.migrate_source_example_json_author.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_json 6 | - taxonomy 7 | id: migrate_source_example_json_author 8 | migration_tags: null 9 | migration_group: migrate_source_example_json 10 | label: Authors 11 | source: 12 | plugin: migrate_source_example_url 13 | data_fetcher_plugin: http 14 | data_parser_plugin: json 15 | urls: /json/attributes 16 | item_selector: author 17 | ids: 18 | author_id: 19 | type: integer 20 | constants: 21 | slash: '/' 22 | fields: 23 | - 24 | name: author_id 25 | label: 'ID of the author' 26 | selector: id 27 | - 28 | name: author_name 29 | label: 'Name of the author' 30 | selector: name 31 | - 32 | name: author_alias 33 | label: 'Alias of the author' 34 | selector: alias 35 | process: 36 | vid: 37 | plugin: default_value 38 | default_value: author 39 | name: author_name 40 | path: 41 | - 42 | plugin: concat 43 | delimiter: null 44 | source: 45 | # Slash needs to be prefixed for the path. 46 | - constants/slash 47 | - author_alias 48 | destination: 49 | plugin: 'entity:taxonomy_term' 50 | migration_dependencies: { } 51 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration.migrate_source_example_json_book.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | config: 5 | - migrate_plus.migration.migrate_source_example_json_category 6 | - migrate_plus.migration.migrate_source_example_json_author 7 | - migrate_plus.migration.migrate_source_example_json_image 8 | - migrate_plus.migration.migrate_source_example_json_user 9 | module: 10 | - migrate_source_example_json 11 | - node 12 | id: migrate_source_example_json_book 13 | migration_tags: null 14 | migration_group: migrate_source_example_json 15 | label: Books 16 | source: 17 | plugin: migrate_source_example_url 18 | data_fetcher_plugin: http 19 | data_parser_plugin: json 20 | urls: /json/books 21 | item_selector: books 22 | ids: 23 | book_id: 24 | type: integer 25 | constants: 26 | slash: '/' 27 | fields: 28 | - 29 | name: book_id 30 | label: 'ID of the book' 31 | selector: id 32 | - 33 | name: book_title 34 | label: 'Title of the book' 35 | selector: title 36 | - 37 | name: book_body 38 | label: 'Body of the book' 39 | selector: body 40 | - 41 | name: book_body_format 42 | label: 'Format of the body' 43 | selector: body_format 44 | - 45 | name: book_image 46 | label: 'Image of the book' 47 | selector: image 48 | - 49 | name: book_author 50 | label: 'Author of the book' 51 | selector: author 52 | - 53 | name: book_category 54 | label: 'Category of the book' 55 | selector: category 56 | - 57 | name: book_user_id 58 | label: 'System creator of the book' 59 | selector: uid 60 | - 61 | name: book_created 62 | label: 'Time created' 63 | selector: created 64 | - 65 | name: book_alias 66 | label: 'Alias of the book' 67 | selector: alias 68 | process: 69 | type: 70 | plugin: default_value 71 | default_value: book 72 | title: book_title 73 | body/value: book_body 74 | body/format: 75 | plugin: static_map 76 | source: book_body_format 77 | map: 78 | 1: plain_text 79 | 2: basic_html 80 | created: 81 | plugin: format_date 82 | format: U 83 | source: book_created 84 | changed: '@created' 85 | uid: 86 | plugin: migration 87 | migration: migrate_source_example_json_user 88 | source: book_user_id 89 | field_cover: 90 | plugin: migration 91 | migration: migrate_source_example_json_image 92 | source: book_image 93 | path: 94 | - 95 | plugin: skip_on_empty 96 | method: process 97 | source: book_alias 98 | - 99 | plugin: concat 100 | delimiter: null 101 | source: 102 | - constants/slash 103 | - book_alias 104 | field_category: 105 | - 106 | plugin: explode 107 | delimiter: ',' 108 | source: book_category 109 | - 110 | plugin: migration 111 | migration: migrate_source_example_json_category 112 | field_author: 113 | plugin: migration 114 | migration: migrate_source_example_json_author 115 | source: book_author 116 | destination: 117 | plugin: 'entity:node' 118 | migration_dependencies: 119 | required: 120 | - migrate_source_example_json_category 121 | - migrate_source_example_json_author 122 | - migrate_source_example_json_image 123 | - migrate_source_example_json_user 124 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration.migrate_source_example_json_category.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_json 6 | - taxonomy 7 | id: migrate_source_example_json_category 8 | migration_tags: null 9 | migration_group: migrate_source_example_json 10 | label: Categories 11 | source: 12 | plugin: migrate_source_example_url 13 | data_fetcher_plugin: http 14 | data_parser_plugin: json 15 | urls: /json/attributes 16 | item_selector: category 17 | ids: 18 | category_id: 19 | type: integer 20 | constants: 21 | slash: '/' 22 | fields: 23 | - 24 | name: category_id 25 | label: 'ID of the category' 26 | selector: id 27 | - 28 | name: category_name 29 | label: 'Name of the category' 30 | selector: name 31 | - 32 | name: category_alias 33 | label: 'Alias of the category' 34 | selector: alias 35 | process: 36 | vid: 37 | plugin: default_value 38 | default_value: category 39 | name: category_name 40 | path: 41 | - 42 | plugin: concat 43 | delimiter: null 44 | source: 45 | - constants/slash 46 | - category_alias 47 | destination: 48 | plugin: 'entity:taxonomy_term' 49 | migration_dependencies: { } 50 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration.migrate_source_example_json_image.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_json 6 | - file 7 | id: migrate_source_example_json_image 8 | migration_tags: null 9 | migration_group: migrate_source_example_json 10 | label: Images 11 | source: 12 | plugin: migrate_source_example_url_image 13 | data_fetcher_plugin: http 14 | data_parser_plugin: json 15 | urls: /json/images 16 | item_selector: images 17 | ids: 18 | image_id: 19 | type: integer 20 | constants: 21 | source_base_path: 'source/images' 22 | destination_base_path: 'public://' 23 | fields: 24 | - 25 | name: image_id 26 | label: 'ID of the image' 27 | selector: id 28 | - 29 | name: image_filename 30 | label: 'Filename of the image' 31 | selector: filename 32 | process: 33 | # Prepare full path of the source. 34 | source_full_path: 35 | - 36 | plugin: concat 37 | delimiter: / 38 | source: 39 | - constants/source_base_path 40 | - image_filename 41 | - 42 | plugin: urlencode 43 | # Prepare full path of the destination. 44 | destination_full_path: 45 | plugin: concat 46 | delimiter: / 47 | source: 48 | - constants/destination_base_path 49 | - image_filename 50 | uri: 51 | plugin: file_copy 52 | source: 53 | - '@source_full_path' 54 | - '@destination_full_path' 55 | destination: 56 | plugin: 'entity:file' 57 | migration_dependencies: { } 58 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration.migrate_source_example_json_user.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_json 6 | - user 7 | id: migrate_source_example_json_user 8 | migration_tags: null 9 | migration_group: migrate_source_example_json 10 | label: Users 11 | source: 12 | plugin: migrate_source_example_url 13 | data_fetcher_plugin: http 14 | data_parser_plugin: json 15 | urls: /json/users 16 | item_selector: users 17 | ids: 18 | user_id: 19 | type: integer 20 | constants: 21 | slash: '/' 22 | fields: 23 | - 24 | name: user_id 25 | label: 'ID of the user' 26 | selector: id 27 | - 28 | name: user_name 29 | label: 'Name of the user' 30 | selector: name 31 | - 32 | name: user_roles 33 | label: 'Roles of the user' 34 | selector: roles 35 | - 36 | name: user_email 37 | label: 'Email of the user' 38 | selector: email 39 | process: 40 | name: 41 | plugin: dedupe_entity 42 | field: name 43 | entity_type: user 44 | source: user_name 45 | roles: 46 | plugin: explode 47 | delimiter: ',' 48 | source: user_roles 49 | mail: user_email 50 | init: user_email 51 | status: 52 | plugin: default_value 53 | default_value: 1 54 | destination: 55 | plugin: 'entity:user' 56 | migration_dependencies: { } 57 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/config/install/migrate_plus.migration_group.migrate_source_example_json.yml: -------------------------------------------------------------------------------- 1 | langcode: en 2 | status: true 3 | dependencies: 4 | module: 5 | - migrate_source_example_json 6 | enforced: 7 | module: 8 | - migrate_source_example_json 9 | id: migrate_source_example_json 10 | label: 'Example migration from a JSON resource.' 11 | description: 'A few example migrations from a JSON resource.' 12 | source_type: 'JSON resource' 13 | module: null 14 | shared_configuration: 15 | # Specifying 'source' here means that this configuration will be merged into 16 | # the 'source' configuration of each migration. 17 | source: 18 | # A better practice for real-world migrations would be to add a database 19 | # connection to your external database in settings.php and reference its 20 | # key here. 21 | key: default 22 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/migrate_source_example_json.info.yml: -------------------------------------------------------------------------------- 1 | name: JSON migration example 2 | type: module 3 | description: Example module that provides content migration from JSON files. 4 | core: 8.x 5 | package: Migration 6 | dependencies: 7 | - migrate_source_example 8 | - migrate_source_example_setup 9 | - migrate_plus 10 | - migrate_tools 11 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/migrate_source_example_json.module: -------------------------------------------------------------------------------- 1 | ' . t('About') . ''; 19 | $output .= '' . t('Example module that provides content migration from JSON files.') . '
'; 20 | return $output; 21 | 22 | default: 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/migrate_source_example_json.routing.yml: -------------------------------------------------------------------------------- 1 | usercontent.page: 2 | path: '/json/users' 3 | defaults: 4 | _controller: '\Drupal\migrate_source_example_json\Controller\UserMigrationController::userContent' 5 | requirements: 6 | _permission: 'access content' 7 | 8 | imagecontent.page: 9 | path: '/json/images' 10 | defaults: 11 | _controller: '\Drupal\migrate_source_example_json\Controller\ImageMigrationController::imageContent' 12 | requirements: 13 | _permission: 'access content' 14 | 15 | attributescontent.page: 16 | path: '/json/attributes' 17 | defaults: 18 | _controller: '\Drupal\migrate_source_example_json\Controller\AttributesMigrationController::attributesContent' 19 | requirements: 20 | _permission: 'access content' 21 | 22 | bookscontent.page: 23 | path: '/json/books' 24 | defaults: 25 | _controller: '\Drupal\migrate_source_example_json\Controller\BooksMigrationController::booksContent' 26 | requirements: 27 | _permission: 'access content' 28 | 29 | 30 | -------------------------------------------------------------------------------- /modules/migrate_source_example_json/source/attributes.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": [ 3 | { 4 | "id": 1, 5 | "name": "Ian Fleming", 6 | "alias": "author/ian-fleming" 7 | }, 8 | { 9 | "id": 2, 10 | "name": "Robert Ludlum", 11 | "alias": "author/robert-ludlum" 12 | }, 13 | { 14 | "id": 3, 15 | "name": "John Ronald Reuel Tolkien", 16 | "alias": "author/jrr-tolkien" 17 | } 18 | ], 19 | "category": [ 20 | { 21 | "id": 1, 22 | "name": "Spy Stories", 23 | "alias": "category/spy-stories" 24 | }, 25 | { 26 | "id": 2, 27 | "name": "Fantasy", 28 | "alias": "category/fantasy" 29 | }, 30 | { 31 | "id": 3, 32 | "name": "Fiction", 33 | "alias": "category/fiction" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /modules/migrate_source_example_json/source/books.json: -------------------------------------------------------------------------------- 1 | { 2 | "books": [ 3 | { 4 | "id": 1, 5 | "title": "Casino Royale", 6 | "body": "M,\nthe Head of the British Secret Service,\nassigns James Bond, 007,\nto play against and bankrupt Le Chiffre,\nthe paymaster for a SMERSH - controlled trade union,\nin a high - stakes baccarat game at the Royale-les-Eaux casino in northern France.", 7 | "body_format": "1", 8 | "image": "1", 9 | "author": "1", 10 | "category": "1", 11 | "uid": "3", 12 | "created": "2015-04-02 21:00:00", 13 | "alias": "casino-royale" 14 | }, 15 | { 16 | "id": 2, 17 | "title": "Live and Let Die", 18 | "body": "The British Secret Service agent James Bond is sent by his superior, M, to New York City to investigate Mr Big, real name Buonaparte Ignace Gallia.
", 19 | "body_format": "2", 20 | "image": "2", 21 | "author": "1", 22 | "category": "1", 23 | "uid": "3", 24 | "created": "2015-05-24 16:30:00", 25 | "alias": "live-and-let-die" 26 | }, 27 | { 28 | "id": 3, 29 | "title": "Moonraker", 30 | "body": "The British Secret Service agent James Bond is asked by his superior, M, to join him at M's club, Blades.
", 31 | "body_format": "2", 32 | "image": "3", 33 | "author": "1", 34 | "category": "1", 35 | "uid": "3", 36 | "created": "2015-06-01 17:25:00", 37 | "alias": "moonraker" 38 | }, 39 | { 40 | "id": 4, 41 | "title": "Diamonds Are Forever", 42 | "body": "The British Secret Service agent James Bond is sent on an assignment by his superior, M.
", 43 | "body_format": "2", 44 | "image": "4", 45 | "author": "1", 46 | "category": "1", 47 | "uid": "3", 48 | "created": "2015-06-14 09:45:00", 49 | "alias": "diamonds-are-forever" 50 | }, 51 | { 52 | "id": 5, 53 | "title": "The Bourne Identity", 54 | "body": "The preface of the novel consists of two real-life newspaper articles from 1975 about terrorist Ilich Ramírez Sánchez, known as Carlos the Jackal.
", 55 | "body_format": "2", 56 | "image": "5", 57 | "author": "2", 58 | "category": "1", 59 | "uid": "1", 60 | "created": "2015-06-15 12:00:00", 61 | "alias": "the-bourne-identity" 62 | }, 63 | { 64 | "id": 6, 65 | "title": "The Bourne Supremacy", 66 | "body": "The story of The Bourne Supremacy is set during the British negotiated handover of Hong Kong to the People's Republic of China on the expiration of its ninety-nine-year lease on the New Territories.
", 67 | "body_format": "2", 68 | "image": "6", 69 | "author": "2", 70 | "category": "1", 71 | "uid": "1", 72 | "created": "2015-06-25 14:45:00", 73 | "alias": "the-bourne-supremacy" 74 | }, 75 | { 76 | "id": 7, 77 | "title": "The Bourne Ultimatum", 78 | "body": "The novel follows David Webb, alias Jason Bourne, as he works to find his old enemy, Carlos the Jackal, who is trying to kill him.
", 79 | "body_format": "2", 80 | "image": "7", 81 | "author": "2", 82 | "category": "1", 83 | "uid": "1", 84 | "created": "2015-07-07 16:15:00", 85 | "alias": "the-bourne-ultimatum" 86 | }, 87 | { 88 | "id": 8, 89 | "title": "The Fellowship of the Ring", 90 | "body": "Thousands of years before the events of the novel, the Dark Lord Sauron had forged the One Ring to rule the other Rings of Power and corrupt those who wear them: the leaders of Men, Elves and Dwarves.
", 91 | "body_format": "2", 92 | "image": "8", 93 | "author": "3", 94 | "category": "2,3", 95 | "uid": "2", 96 | "created": "2015-07-14 18:30:00", 97 | "alias": "" 98 | }, 99 | { 100 | "id": 9, 101 | "title": "The Two Towers", 102 | "body": "Orcs sent by Saruman and Sauron kill Boromir and kidnap Merry and Pippin. After agonizing over which pair of hobbits to follow, Aragorn, Gimli and Legolas pursue the orcs bearing Merry and Pippin to Saruman.
", 103 | "body_format": "2", 104 | "image": "9", 105 | "author": "3", 106 | "category": "2,3", 107 | "uid": "2", 108 | "created": "2015-07-18 20:45:00", 109 | "alias": "" 110 | }, 111 | { 112 | "id": 10, 113 | "title": "The Return of the King", 114 | "body": "Sauron unleashes a heavy assault upon Gondor. Gandalf arrives at Minas Tirith to alert Denethor of the impending attack.
", 115 | "body_format": "2", 116 | "image": "10", 117 | "author": "3", 118 | "category": "2,3", 119 | "uid": "2", 120 | "created": "2015-07-28 09:15:00", 121 | "alias": "" 122 | } 123 | ] 124 | } -------------------------------------------------------------------------------- /modules/migrate_source_example_json/source/images.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "id": 1, 5 | "filename": "casino-royale.png" 6 | }, 7 | { 8 | "id": 2, 9 | "filename": "live-and-let-die.png" 10 | }, 11 | { 12 | "id": 3, 13 | "filename": "moonraker.png" 14 | }, 15 | { 16 | "id": 4, 17 | "filename": "diamonds-are-forever.png" 18 | }, 19 | { 20 | "id": 5, 21 | "filename": "bourne-identity.png" 22 | }, 23 | { 24 | "id": 6, 25 | "filename": "bourne-supremacy.png" 26 | }, 27 | { 28 | "id": 7, 29 | "filename": "bourne-ultimatum.png" 30 | }, 31 | { 32 | "id": 8, 33 | "filename": "fellowship-of-the-ring.png" 34 | }, 35 | { 36 | "id": 9, 37 | "filename": "two-towers.png" 38 | }, 39 | { 40 | "id": 10, 41 | "filename": "return-of-the-king.png" 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /modules/migrate_source_example_json/source/users.json: -------------------------------------------------------------------------------- 1 | { 2 | "users": [ 3 | { 4 | "id": 1, 5 | "name": "Nifs", 6 | "roles": "administrator,editor", 7 | "email": "nifs@nifs.com" 8 | }, 9 | { 10 | "id": 2, 11 | "name": "Nufs", 12 | "roles": "editor", 13 | "email": "nufs@nufs.com" 14 | }, 15 | { 16 | "id": 3, 17 | "name": "Nafs", 18 | "roles": "editor", 19 | "email": "nafs@nafs.com" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /modules/migrate_source_example_json/src/Controller/AttributesMigrationController.php: -------------------------------------------------------------------------------- 1 | applyUpdates(); 15 | } 16 | catch (EntityStorageException $e) { 17 | watchdog_exception('migrate_source_example_setup', $e); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /modules/migrate_source_example_setup/migrate_source_example_setup.module: -------------------------------------------------------------------------------- 1 | ' . t('About') . ''; 19 | $output .= '' . t('Example module that provides content migration from XML files') . '
'; 20 | return $output; 21 | 22 | default: 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/migrate_source_example_xml/source/attributes.xml: -------------------------------------------------------------------------------- 1 | 2 |