Add API documentation. Make sure that configuration parameters and working with translations are included. Add suitable examples too.

See the documentation in the process plugins for format examples.

Comments

quietone created an issue. See original summary.

jofitz’s picture

Status: Active » Needs review
StatusFileSize
new1.69 KB

This one is also a bit tricky, but here's a start. I have added:

  • available configuration key(s)
  • a simple example
  • a second example incorporating the translation config key

I couldn't identify destination properties the same as I did with #2862655: Add documentation to Config destination plugin and #2862751: Add documentation to PerComponentEntityDisplay destination plugin.

ohthehugemanatee’s picture

Status: Needs review » Needs work

Great start, and good examples.

* "the destination is for translations" is hard to understand. It would be clearer as "the destination will be associated with the langcode provided by the source plugin."
* I would remove the "signature/value" key from the second example entirely; it's just confusing and doesn't provide anything the mail and name keys don't already.
* "This will add the results of the process..." would be clearer as "This will migrate mapped data ("nid" and "uid") into a "user" entity". This change can apply to both descriptive sentences.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

masipila’s picture

Issue tags: +API Documentation
masipila’s picture

Status: Needs work » Needs review
StatusFileSize
new2.07 KB
new3.1 KB

I changed the example from a user migration to a node migration because we are demonstrating the overwrite_properties configuration key in the example and overwriting user account data is a bit too dangerous to be used as an example in my opinion.

The interdiff is included but does not make much sense as the example is changed.

Cheers,
Markus

Status: Needs review » Needs work

The last submitted patch, 6: 2862662-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

I don't know about the 'dangers' of overwrite properties and the user migration but in changing the example, I think we have lost part of what is happening here. That is, what is happening to other properties provided by the source plugin and not listed in overwrite_properties. In that regard, we could use the d6_node source plugin and explain what happens to those properties. Still I have seen a fair number of questions about user migration and passwords. maybe it should be reverted? Not sure, I can be convinced either way.

+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
@@ -17,7 +17,48 @@
+'      content: '<p>Hello world</p>'

Typo s/'/*/

masipila’s picture

My concern on using the user migration as an example is this:

  • Let's say that users have been migrated to D8
  • New users have been created to D8
  • If the user migration is executed again, it is very likely that there will be ID conflicts and the migration will overwrite user account created in D8.
  • The same thing of of course applies also to node migrations but it would not be as fatal as the user ID conflict.

I do agree, however, that the user migration needs to be documented but we already have a handbook page for that purpose and that handbook page includes the password hashes, see https://www.drupal.org/docs/8/api/migrate-api/migrate-destination-entity...

I'll propose the following for this API documentation:

  • Let's have two examples: one for user migration and another for node migration
  • Let's use the user migration as the first example without the optional overwrite_properties configuration and let's add a link to the handbook page for more details on the password handling.
  • Let's use the node migration as the second example which is more complex and discusses the overwrite_properties configuration.

Patch will follow shortly.

Markus

masipila’s picture

Hmm.. Continuing to think out loud regarding the user migration example.

I don't think that the user migration example belongs here to EntityContentBase destination plugin. We have a separate subclass EntityUser for migrating user entitities and that destination plugin has the capabilities for the password MD5 hashes.

I created a follow-up to improve the API documentation of EntityUser, see #2933310: Add documentation to EntityUser destination plugin.

Cheers,
Markus

masipila’s picture

Status: Needs work » Needs review
StatusFileSize
new2.19 KB
new1.95 KB

Changes since #6: Added a third field which will be preserved in an update. Improved phrasing.

quietone’s picture

Status: Needs review » Needs work

I like what your idea in #10, makes a lot more sense.

The patch reads well. I wondered about the key 'translations'. There isn't an example of it's use here, I found it on the parent class, Entity.php. That makes sense but maybe there should be a comment that an example of the usage of translations can be found in Entity.php, with a link to it? That way it will be easy to find. What do you think?

masipila’s picture

Status: Needs work » Needs review
StatusFileSize
new2.47 KB
new2.37 KB

I added the translation to the example directly so that the developer doesn't have to jump back and forth but can get a comprehensive example from here (also changed the example values to Finnish).

I also re-phrased the text so that we don't 'hard code' the destination version to Drupal 8.

Markus

quietone’s picture

Status: Needs review » Reviewed & tested by the community

Yes, good idea to change the reference from Drupal 8 to the destination site. This looks good to me now.

masipila’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.54 KB
new565 bytes

Added a 'see also' reference to \Drupal\migrate\Plugin\migrate\destination\EntityRevision. See #2862748: Add documentation to EntityRevision destination plugin. These two patches should be preferably be committed at the same time.

Cheers,
Markus

EDIT: Fixed the correct issue number for EntityRevision.

masipila’s picture

heddn’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -17,7 +17,61 @@
    + * - overwrite_properties: (optional) A list of properties that will be
    + *   overwritten if an entity with the same ID already exists.
    

    Is this always overwritten, even if the update flag wasn't passed when running the migration?

    Update: I see this is mentioned later. But can we work it into the initial short description too?

  2. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -17,7 +17,61 @@
    + *   plugin: empty
    

    Might try using the embedded source plugin instead of empty.

harsha012’s picture

Status: Needs work » Needs review
StatusFileSize
new2.55 KB
new871 bytes

improved on the doc section.

heddn’s picture

Status: Needs review » Needs work

#18 doesn't see to address any of the feedback points in #17.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.33 KB
new2.17 KB

Addressed the feedback from #17 (ignoring the patch in #18).

heddn’s picture

Status: Needs review » Reviewed & tested by the community

All my feedback is addressed. On to RTBC.

masipila’s picture

Status: Reviewed & tested by the community » Needs work

Let's use the embedded_data source plugin instead of d7_node (see #17) so that we are providing a working stand-alone example. In addition to this, the patch #15 gave an explicit example on how the fields are overwritten on update because the source data was visible in the example.

I can take this on Friday if this hasn't been worked before that.

Markus

heddn’s picture

Issue tags: +Migrate January 2017 Sprint
heddn’s picture

Issue tags: -Migrate January 2017 Sprint +Migrate January 2018 Sprint
heddn’s picture

Issue tags: +Novice
masipila’s picture

Assigned: Unassigned » masipila

Working on this now.

masipila’s picture

Assigned: masipila » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.59 KB
new2.31 KB

The attached patch uses #15 as the basis and changes the source plugin to EmbeddedDataSource as heddn suggested in #17 (and fixes the typo Jo spotted in his patch + adds the claficication from Jo's patch).

Cheers,
Markus

heddn’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

All feedback is addressed. On to RTBC.

masipila’s picture

Assigned: Unassigned » masipila
Status: Reviewed & tested by the community » Needs work

Argh. The previous patch is missing the ids part of the embedded data source... fixing right now... sooorrry.

masipila’s picture

Assigned: masipila » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.63 KB
new576 bytes

And now it should be done.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Oops. Missed that. Now I think we are good to go.

  • Gábor Hojtsy committed 9d4f798 on 8.5.x
    Issue #2862662 by masipila, Jo Fitzgerald, heddn, quietone,...
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.